segue没有传递数据

时间:2014-07-21 08:09:46

标签: ios xcode parse-platform

我仍然遇到我的segue问题 我现在有

- (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:@"WeddingDetail"]){

    // 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];

    // Set destination view controller to DetailViewController to avoid the NavigationViewController in the middle (if you have it embedded into a navigation controller, if not ignore that part)
    UINavigationController *nav = [segue destinationViewController];
    DMKWeddingDetailViewController *detailViewController = (DMKWeddingDetailViewController *) nav.nextResponder;
    detailViewController.exam = object;
    NSLog(@"object details: %@",object);
}
}

我希望考试能保存数据,但不是数据保存在对象中。但不确定如何将对象传递给详细视图控制器。

在我的detailview控制器中,我有一个列表,如果textlabels

self.name.text = [self.exam objectForKey:@"name"];

但他们没有填充

1 个答案:

答案 0 :(得分:0)

如果目标ViewController是UINavigationController,我认为问题在于

DMKWeddingDetailViewController *detailViewController = (DMKWeddingDetailViewController *) nav.nextResponder;

你应该使用它

DMKWeddingDetailViewController *detailViewController = (DMKWeddingDetailViewController *) [nav topViewController];

如果目标是您的目标ViewController,您应该使用

DMKWeddingDetailViewController *detailViewController = (DMKWeddingDetailViewController *) [segue destinationViewController];