本文介绍私人通信录相关的联系人删除相关的操做,涉及如下知识点:面试
做为一个开发者,有一个学习的氛围跟一个交流圈子特别重要,这是一个个人iOS交流群:812157648,无论你是小白仍是大牛欢迎入驻 ,分享BAT,阿里面试题、面试经验,讨论技术, 你们一块儿交流学习成长!markdown
commitEditingStyle
方法,列表项向左滑动会出现删除按钮commitEditingStyle
方法中本身实现删除数据并刷新界面- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
if (editingStyle==UITableViewCellEditingStyleDelete) {
//删除数据
[self.contacts removeObjectAtIndex:indexPath.row];
//刷新界面
//[self.tableView reloadData];//全局刷新
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];//删除局部
}
NSLog(@"%ld",indexPath.row);
}
复制代码
didUpdateContact
方法是更新联系人要实现的方法-(void)editViewController:(EditViewController *)edit didUpdateContact:(Contact *)contact
{
//刷新表格
//[self.tableView reloadData];//所有刷新
NSIndexPath *selectIndex=[self.tableView indexPathForSelectedRow];
[self.tableView reloadRowsAtIndexPaths:@[selectIndex] withRowAnimation:UITableViewRowAnimationLeft];
//归档
[NSKeyedArchiver archiveRootObject:self.contacts toFile:FilePath];
}
复制代码
依次选择:项目——>Locallization——>+,在弹出的语言列表中选择中文简体oop
原文做者:PGzxc学习
原文地址:blog.csdn.net/Calvin_zhou…spa