Chr*_*ins 2 cocoa-touch objective-c ios segue
这可能需要两秒钟才能回答,但我的搜索技巧并没有让我在这个问题上走得太远.我正在执行一个赛格但我不确定如何抓住目的地的身份证.这是我在tableview控制器上的代码.
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath: NSIndexPath *)indexPath{
NSLog(@"reaching accessoryButtonTappedForRowWithIndexPath:");
[self performSegueWithIdentifier:@"leads_calls_to_detail" sender:[[self.leads_calls objectAtIndex:indexPath.row] objectForKey:@"ID"]];
}
Run Code Online (Sandbox Code Playgroud)
我必须在目标视图控制器上创建什么才能获取我试图传递的ID,或者我正在执行我的segue与我正在尝试的内容不兼容的方式?
你应该只将值传递给destinationViewController内部prepareForSegue:并self作为发送者传递..尝试使用类似的东西:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"leads_calls_to_detail"])
{
YourViewController *controller=(YourViewController *)segue.destinationViewController;
NSIndexPath *path = [self.tableView indexPathForSelectedRow];
//Or rather just save the indexPath in a property in your currentViewController when you get the accessoryButtonTappedForRowAtIndexPath callback, and use it here
controller.yourPropertyToSet = [self.leads_calls objectAtIndex:path.row];
}
}
Run Code Online (Sandbox Code Playgroud)
而且根据Rob Mayoff的说法,你可以通过使用以下内容获取附件被点击的行的索引路径:
NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];//where sender is the sender passed in from prepareForSegue:
Run Code Online (Sandbox Code Playgroud)
如何在tableView中找到tapPath附件按钮的indexPath
| 归档时间: |
|
| 查看次数: |
3771 次 |
| 最近记录: |