我需要在已定义的函数中删除表的第1行。为了使用,deleteRowAtIndexPath
您必须使用已IndexPath
定义部分和行的。我如何创建这样的索引路径?
以int {1}作为其唯一成员的数组将崩溃;NSLog消息指出该部分也需要定义。
*编辑->与单元格删除有关的代码:
NSIndexPath *myIP = [[NSIndexPath alloc] indexPathForRow:0 inSection:0];
NSArray *myArray = [[NSArray alloc] initWithObjects:myIP, nil];
// [self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:myArray withRowAnimation:UITableViewRowAnimationFade];
// [self.tableView endUpdates];
使用[NSIndexPath indexPathForRow:inSection:]
快速创建一个索引路径。
编辑:在Swift 3:
let indexPath = IndexPath(row: rowIndex, section: sectionIndex)
迅捷5
IndexPath(row: 0, section: 0)
indexPathForRow
是一个类方法!
该代码应显示为:
NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0] ;
Swift中的强制性答案: NSIndexPath(forRow:row, inSection: section)
您会注意到该NSIndexPath.indexPathForRow(row, inSection: section)
功能不是很快可用的,必须使用第一种方法来构造indexPath。
对于Swift 3,现在是: IndexPath(row: rowIndex, section: sectionIndex)
本文地址:http://ios.askforanswer.com/ruheweitableviewchuangjiannsindexpath.html
文章标签:ios , iphone , nsindexpath , uitableview
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!
文章标签:ios , iphone , nsindexpath , uitableview
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!
评论已关闭!