Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何获取传递给performsguewithidentifier的数据_Ios_Objective C_Cocoa Touch_Segue - Fatal编程技术网

Ios 如何获取传递给performsguewithidentifier的数据

Ios 如何获取传递给performsguewithidentifier的数据,ios,objective-c,cocoa-touch,segue,Ios,Objective C,Cocoa Touch,Segue,回答这个问题可能需要两秒钟,但我的搜索技能并没有让我在这个问题上走得很远。我正在执行一个segue,但我不确定如何获取目标上的id。这是我在tableview控制器上的代码 - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath: NSIndexPath *)indexPath{ NSLog(@"reaching accessoryButtonTappedForRowWithI

回答这个问题可能需要两秒钟,但我的搜索技能并没有让我在这个问题上走得很远。我正在执行一个segue,但我不确定如何获取目标上的id。这是我在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"]];
}

我必须在目标视图控制器上创建什么才能获取我试图传递的id,或者我执行序列的方式是否与我正在尝试的不兼容?

您应该将值传递给
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];
    }
}
根据Rob Mayoff的说法,您可以通过如下方式获取附件所在行的索引路径:

NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];//where sender is the sender passed in from prepareForSegue:

您需要实现一个,在其中您可以参考segue.destinationController。谢谢!我想我可以从这里找到答案!:)