开发者

When editing UITableView, clicking red dot fails to display 'Delete' button

A table view is contained in a regular view.

As expected, taping 'Edit' button (in that table view) displays 'red dot with minus sign' for each row (that is, method 'setEditing' executes OK).

However, clicking such red dot does NOT display the corresponding 'Delete' button ('commitEditingStyle' does NOT execute).

Any idea on what could be wrong (see relevant code below)?

//---- 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.leftBarButt开发者_如何学运维onItem = 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.
    ...
}


Double check that you've wired up both your table's UITableViewDelegate and UITableViewDataSource correctly to the new UIViewController you've written.


Make sure that cell.editingAccessoryView is set to nil in:

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
 cell.editingAccessoryView = nil;
}


you are not implement tableView protocol's in your .h .. you class interface should be like this

@interface RootViewController : UIViewController <NSFetchedResultsControllerDelegate, UITableViewDelegate,UITableViewDataSource>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜