【发布时间】:2012-04-10 02:54:45
【问题描述】:
我正在使用带有故事板的 xcode 4.2 来创建一个 iphone 应用程序。
当我按下右上角的编辑按钮时,我希望可以选择删除现有行并在顶部看到额外的单元格(带有绿色“+”图标),这将允许我添加一个新单元格。
我有一个数组,它使用 CoreData 在 viewDidLoad 方法中填充
我已启用设置按钮
self.navigationItem.rightBarButtonItem = self.editButtonItem;
并实现了方法
- (void)tableView:(UITableView *)tableView commitEditingStyle:
(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// removing a cell from my array and db here...
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// adding a cell to my array and db here...
}
}
我意识到我需要在某个时候添加单元格,然后我可以对其进行编辑,但我不清楚在哪里,而且我无法在互联网上找到解释。
【问题讨论】:
标签: iphone ios uitableview storyboard