开发者

when editButtonItem clicked, no red delete icon shows

I am writing an IPhone IM chat window now.

You know if t开发者_如何学Pythonhe nagviationItem.rightBarItem in an UITableviewController is set to editButtonItem, you click the edit button then a red delete icon is shown to every single row, like shown here.

The problem is, I have a UIViewController instead of a UITableViewController:

@interface ChatUIViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>{
    UITableView *table;
    UITextField *textField;

}

and i did same to set editButtonItem:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.rightBarButtonItem = self.editButtonItem;

}

when i click the edit button, the red delete icon will not show.

How can I make the red delete icon shown in my ChatUIViewController?

Thanks in advance to anyone who might help. Michael


Add the following method to your table view delegate class:

- (void) setEditing:(BOOL)editing animated:(BOOL)animated {
    [super setEditing:editing animated:animated];
    [self.tableView setEditing:editing animated:animated];
    if (editing) {
        // you might disable other widgets here... (optional)
    } else {
        // re-enable disabled widgets (optional)
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜