本文介绍了indexPath.row 使用 didSelectRow 正确返回,但使用附件按钮Tapped 返回不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"editInfo" sender:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"editInfo"]) {
EditInfoViewController *vc = [segue destinationViewController];
NSInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
NSLog(@"%d",selectedIndex);
[vc setSelectedIndex:selectedIndex];
}
else if ([[segue identifier] isEqualToString:@"sendMessage"]) {
...
}
}
selectedIndex 变量总是 NSLogged 为 0...有什么建议吗?谢谢.
The selectedIndex variable is always NSLogged as 0... Any suggestions? Thanks.
推荐答案
点击 UITableViewCell 的附件按钮不会选择包含附件按钮的行.
Tapping a UITableViewCell's accessoryButton doesn't select the row containing the accessoryButton.
当您调用 performSegueWithIdentifier
时,您可以将 indexPath
作为 sender
传递,然后您可以在 prepareForSegue
中引用它>.
When you call performSegueWithIdentifier
, you could pass indexPath
as the sender
, which you could then reference in prepareForSegue
.
这篇关于indexPath.row 使用 didSelectRow 正确返回,但使用附件按钮Tapped 返回不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!