我需要在我已经定义的功能的表的删除行1。为了使用deleteRowAtIndexPath你必须使用一个IndexPath与限定的区间和行。我怎样才能创建这样一个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:]快速创建的索引路径。

修改在夫特3:

let indexPath = IndexPath(row: rowIndex, section: sectionIndex)

其他提示

indexPathForRow是一个类方法!

代码应为:

NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0] ;

在夫特强制性答案:NSIndexPath(forRow:row, inSection: section)

您会注意到NSIndexPath.indexPathForRow(row, inSection: section)不迅速可用,您必须使用第一种方法来构建indexPath。

有关夫特3它现在:IndexPath(row: rowIndex, section: sectionIndex)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top