简体   繁体   English

从View控制器导航烘焙时删除tableview单元格

[英]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.

相关问题 如何在表格视图单元格上按以向视图控制器显示导航控制器中的文本 - How to press on a tableview cell to present a view controller with the text in navigation controller 从tableview看到导航控制器之前的视图 - Segue from tableview to view preceded by navigation controller 使用TableView向视图控制器添加导航 - Adding a Navigation to a View Controller with a TableView Swift:当用户点击Tableview单元格时,如何将数据从一个视图控制器转移到另一个 - Swift: How to SHIFT data from one view controller to another when the user taps on the Tableview Cell TableView 被分配给导航控制器而不是视图控制器 - TableView being assigned to navigation controller not view controller 将数据从 tableview 单元格传递到 View Controller Swift 2.1 - Passing data from tableview cell to View Controller Swift 2.1 将字符串从TableView单元格传递到Swift 3中的View Controller - Passing a string from a TableView cell into a View Controller in Swift 3 从collectionview中的Tableview单元导航到查看控制器 - Navigate to view controller from Tableview cell inside collectionview 当按下表格单元格时,将视图加载到导航视图控制器中 - Load view into navigation view controller when table cell is pressed 单击不同的TableView单元格之前,TableView单元格不会加载View Controller - TableView Cell not loading View Controller until Different TableView Cell is clicked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM