2011-11-08 164 views
0

我試圖刪除使用Xcode 4.2和故事板的行。該表嵌套在嵌套在UITabBarController中的UINavigationController中。無法從UITableView中刪除行(從不出現刪除按鈕)

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,我

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSLog(@"hi2"); 
} 

方法不會被調用。

謝謝!

回答

0

檢查方法- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath是否爲YES返回適當的索引路徑。

+0

謝謝。就是這樣。似乎總是缺少一點細節。 :) –