我有一个UIViewController类,有一个tableView。在viewDidLoad中:UITableView在编辑模式 - '编辑'按钮不会改变状态
UIBarButtonItem *editIcon = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem: UIBarButtonSystemItemEdit
target:self
action:@selector(toggleEditMode)] autorelease];
在TE法 'toggleEditMode':
-(void)toggleEditMode{
if(self.theTable.editing) {
[theTable setEditing:NO animated:YES];
[self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStylePlain];
}
else if ([callsArray count]!=0){
[theTable setEditing:YES animated:YES];
[self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone];
}
}
的问题是,编辑按钮不会改变做 '完成'。少了什么东西?我把所有的方法声明:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
感谢,
RL
完美。 只是(编辑)if(theTable.editing),因为de tableView是一个IBOutlet只是改变。该类不是从UITableViewController继承的。 谢谢, RL – 2011-03-20 14:17:04
不客气。 :) – AechoLiu 2011-03-20 21:58:04
尽管这是一个老问题,但它帮助我意识到我忘了[super setEditing:editing animated:animated];这是我矿难的原因。 ;)感谢您发布此信息。 – DataJock 2013-06-21 17:12:37