[英]delete tableview cell when navigation bake from View controller
In my iOS app I am using Core Data to show data on a table view this is working fine . 在我的iOS应用程序中,我使用Core Data在表视图上显示数据,效果很好。
what i want to do is : 我想做的是:
when clicking on the navigation back button of view controller i want 当我单击视图控制器的导航后退按钮时
to delete tableview cell if the textview on the View controller is empty . 如果View控制器上的textview为空,则删除tableview单元格。
i want to do it like Apple note app . 我想像Apple Note App那样做。
can any one hellp me with sample code please 有人可以用示例代码帮助我吗
here is my code to check if textview is empty or not 这是我的代码来检查textview是否为空
if( self.info .text.length <= 0 ){
}
1.Make sure your DataSource is something like this a 1,确保你的数据源是这样的
NSMutableArray *dataSource = [NSMutableArray alloc]initWitObjects:@"One",@"Two",@"Three",@"Four",@"Five",nil];
2.Remove wanted objects from your dataSource like so 2,像这样从数据源中删除想要的对象
[dataSource removeObjectAtIndex:2];
Delete rows in UITableView with animation 使用动画删除UITableView中的行
Create indexPaths to delete like this 创建indexPaths这样删除
NSArray *deleteIndexPaths = [[NSArray alloc] initWithObjects:
[NSIndexPath indexPathForRow:2 inSection:0],
nil];
Finally delete them from the tableView like this 最后像这样从tableView中删除它们
[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
Or you can simply call 或者您可以简单地致电
[self.tableView reloadData];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.