从tableview控制器传递详细信息

时间:2014-11-03 19:38:14

标签: xcode parse-platform

我正在尝试推送我的详细信息视图我正在使用PFQueryTableView并且我认为它与正常情况一样,因此我使用它。

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

// Check that a new transition has been requested to the DetailViewController and prepares for it
if ([segue.identifier isEqualToString:@"destinationViewController"]){

            // Capture the object (e.g. exam) the user has selected from the list
            NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
            PFObject *object = [self.objects objectAtIndex:indexPath.row];
          dettailViewController *controller = (dettailViewController *) segue.destinationViewController;
           controller.clinics  = object;

}

}

但它在*控制器线上轰炸我在故事板上有一个导航控制器。

当我说它爆炸时,它会在这里抱怨

PFObject * object = [self.objects objectAtIndex:indexPath.row];         vc.clinics = object;  并说出线程错误

1 个答案:

答案 0 :(得分:0)

如果您使用的是导航控制器,则需要在segue中指定导航控制器,如下所示:

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

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


    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    PFObject *object = [self.objects objectAtIndex:indexPath.row];

    UINavigationController *nav = [segue destinationViewController];
    EventDetail *detailViewController = (EventDetail *) nav.topViewController;
    detailViewController.event = object;
  }
}