我如何使用详细披露按钮蒙山故事板?(How I can use the Detail Disclos

2019-09-18 15:39发布

我尝试使用详细披露按钮,用故事板,但是当我从建立公开按钮SEGUE到一个新的查看它的工作原理只是,当我按下表格单元格,而不是当我按下详细披露按钮。

我必须做什么?

谢谢,

伯恩哈德

Answer 1:

我可能是错的,但我发现,它需要通过UITableDelegate代码来实现:

#pragma mark - Table view delegate methods

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
    // do a segue based on the indexPath or do any setup later in prepareForSegue
    [self performSegueWithIdentifier:@"segueName" sender:self];
}

然后在您的prepareForSegue

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

    if([segue.identifier isEqualToString:@"segueName"]){

        NSIndexPath * indexPath =  self.sequenceTableView.indexPathForSelectedRow;
       // do some prep based on indexPath, if needed

     }
}


Answer 2:

skinnyTOD的答案是罚款。 但我不知道为什么self.sequenceTableView.indexPathForSelectedRow; 返回nil(0x0000000),我必须用一个属性来保存selectedRow在accessoryButtonTappedForRowWithIndexPath:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
    // do a segue based on the indexPath or do any setup later in prepareForSegue
    self.selectedRow = indexPath.row;
    [self performSegueWithIdentifier:@"segueName" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"segueName"]) {
        // use self.selectedRow here
    }
}


文章来源: How I can use the Detail Disclosure Button whith Storyboard?