标题说明了一切。当 UITableView 处于编辑模式时,我需要使选择 UITableViewCells
成为可能。我认为这里不需要代码,但万一是:
-(void)turnEditingOn {
[self.tableView setEditing:YES animated:YES];
if (self.tableView.isEditing)
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(newItem)];
else
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(turnEditingOn)];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(turnEditingOn)];
//the rest of the code is omitted
}
所以我需要能够在编辑模式下点击单元格,就像编辑闹钟时的时钟应用程序一样。
谢谢
编辑
忘了说:
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
和
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
在编辑模式下没有被调用
最佳答案
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.allowsSelectionDuringEditing = YES;
}
关于objective-c - UITableView 处于编辑模式时可选择的 UITableViewCells,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9619074/