Ios 将accessoryButtonTappedForRowWithIndexPath转换为didSelectRowAtIndexPath

Ios 将accessoryButtonTappedForRowWithIndexPath转换为didSelectRowAtIndexPath,ios,xcode,segue,didselectrowatindexpath,Ios,Xcode,Segue,Didselectrowatindexpath,我目前已经实现了这个方法 -(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{ // Search the View controller form the cell specified. UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; self

我目前已经实现了这个方法

-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{
// Search the View controller form the cell specified.
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
self.cellPhrase = cell.textLabel.text;
NSLog(@"cellPhrase %@", self.cellPhrase);

// Perform the segue.
[self performSegueWithIdentifier:@"phraseSelectionSegue" sender:self];
}

这是可行的,但这意味着我只能继续使用小的I图标,而不是整个单元格,所以我想改为didselectrowatinexpath

所以我实现了这个方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Search the View controller form the cell specified.
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    self.cellPhrase = cell.textLabel.text;
    NSLog(@"cellPhrase %@", self.cellPhrase);

    // Perform the segue.
    [self performSegueWithIdentifier:@"phraseSelectionSegue" sender:self];
}
然后,我将附件移动到披露指示器,并确保我的Segue push选择Segue

但是,当我运行应用程序时,它似乎无法运行


我想知道是否有人知道原因

检查tableView的
AllowSelection
值。如果该值为false,单元格将不会触发didSelectRowAtIndexPath。

是否有错误?那代码会被执行吗?tableView的
AllowSelection
属性的值是多少?非常感谢pbasdf我忘记了AllowSelection属性。请你把它写下来作为一个答案,这样我就可以把它标记为正确的了。谢谢