2012-03-08 70 views
3

標題說明了一切。當UITableView處於編輯模式時,我需要選擇UITableViewCells。我不認爲代碼在這裏是必需的,但如果它是:當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 

沒有得到所謂的編輯模式

回答

8
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.tableView.allowsSelectionDuringEditing = YES; 
}