【发布时间】:2011-03-18 17:00:35
【问题描述】:
表格视图包含在常规视图中。
正如预期的那样,点击“编辑”按钮(在该表格视图中)为每一行显示“带减号的红点”(即方法“setEditing”执行正常)。
但是,单击此类红点不会显示相应的“删除”按钮(“commitEditingStyle”不会执行)。
任何想法可能是错误的(见下面的相关代码)?
//---- RootViewController.h ----
@interface RootViewController : UIViewController <NSFetchedResultsControllerDelegate> { //used to be a 'UITableViewController'. Changed to UIViewController and rewired so I could add an iAd banner and the tableView to it. Before that change, issue was not present (commitEditingStyle below used to work).
...
}
@property (nonatomic, retain) IBOutlet UITableView *tableView;
//----- RootViewController.m ----
- (void)viewDidLoad {
self.navigationItem.leftBarButtonItem = self.editButtonItem;
...
}
- (void) setEditing:(BOOL)editing animated:(BOOL)animated { //Added so clicking 'Edit' displays red dots that rotate on tap (as expected).
[super setEditing:editing animated:animated];
[self.tableView setEditing:editing animated:animated];
if (editing) {
NSLog(@"RootViewController setEditing"); //Executes OK.
}
}
- (void)tableView:(UITableView *)tableView //Clicking a red dot no longer executes this method (so, does not display 'Delete' red button).
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"RootViewController commitEditingStyle"); //Does NOT execute.
...
}
【问题讨论】:
-
使表格单元格看起来像的代码是什么?它们是如何布局的?
-
你有没有弄清楚这里发生了什么?
标签: iphone cocoa-touch ios4