4
我已經創建了使用UIViewController(而不是UITableViewController)並將UITableView作爲其屬性的表。 我已經實現了DataSource和Delegate協議的必要方法。但是當我點擊編輯按鈕時,我沒有看到它的單元格有任何刪除(紅色減號),所以我可以選擇它們刪除。 如果我使用UITableViewController,同樣工作正常。我已經實施了以下方法。使用UIViewController創建的UITableView編輯功能
我錯過了它在使用標準UITableViewController時行爲不符合它的方式嗎?
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
self.navigationItem.rightBarButtonItem.enabled = !editing;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
感謝onegray,它的作品! – theiOSguy