我试图删除一行使用Xcode 4.2和一个故事板。表嵌套在UINavigationController
中,UITabBarController
中嵌套。
我的UITableViewDelegate
类实现以下代码:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCellEditingStyle result = UITableViewCellEditingStyleNone;
if ([tableView isEqual:self.tableView]==YES) {
result = UITableViewCellEditingStyleDelete;
NSLog(@"hi");
}
return result;
}
,当我滑动一行时,我在日志中看到"hi"
消息,但该行从未收到"删除"按钮。比如http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1, my
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"hi2");
}
方法不被调用。
谢谢!
检查- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
方法是否为合适的索引路径返回YES
。