我尝试将详细信息披露按钮与故事板一起使用,但是当我从Disclosure Button构建一个segue到一个新视图时,它只能按下表格单元格,而不是当我按下详细信息披露按钮时。
我该怎么办?
谢谢,
哈德
答案 0 :(得分:5)
我可能错了,但我发现它需要通过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
}
}
答案 1 :(得分:0)
skinnyTOD的答案很好。但我不知道为什么self.sequenceTableView.indexPathForSelectedRow;返回nil(0x0000000),我必须使用一个属性来保存selectedButtonTappedForRowWithIndexPath中的selectedRow:
- (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
}
}