IOS 开发之UITableView 删除表格单元写法
IOS开发之UITableView删除表格单元写法
实现代码:
-(void)tableView:(UITableView*)aTableViewcommitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath*)indexPath{
if(editingStyle==UITableViewCellEditingStyleDelete){
NSDictionary*section=[dataobjectAtIndex:indexPath.section];
if(section){
NSMutableArray*content=[sectionvalueForKey:@"content"];
if(content&&indexPath.row<[contentcount]){
[contentremoveObjectAtIndex:indexPath.row];
}
}
[tableViewdeleteRowsAtIndexPaths:[NSArrayarrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationFade];
}
elseif(editingStyle==UITableViewCellEditingStyleInsert){
NSDictionary*section=[dataobjectAtIndex:indexPath.section];
if(section){
//Makealocalreferencetotheeditingviewcontroller.
EditingViewController*controller=self.editingViewController;
NSMutableArray*content=[sectionvalueForKey:@"content"];
//A"nil"editingItemindicatestheeditorshouldcreateanewitem.
controller.editingItem=nil;
//Thegrouptowhichthenewitemshouldbeadded.
controller.editingContent=content;
controller.sectionName=[sectionvalueForKey:@"name"];
controller.editingTypes=[sectionvalueForKey:@"types"];
[self.navigationControllerpushViewController:controlleranimated:YES];
}
}
}
那一行是要自己添加的然后把新加那一行的属性设置成UITableViewCellEditingStyleInsert就行了
如有疑问请留言或者到本站社区交流讨论,以上就是IOS中UITableView删除表格单元写法的实例,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短