Xcode 如何从rootViewController中的多级导航更新detailViewController.detailItem

Xcode 如何从rootViewController中的多级导航更新detailViewController.detailItem,xcode,uisplitviewcontroller,ipad,Xcode,Uisplitviewcontroller,Ipad,这是我的第一篇帖子,所以请温柔一点 我在xcode中使用基本的基于分割视图的应用程序,但是已经对其进行了编辑,这样rootViewController就不会简单地更新detailViewController,而是将一个新的UITableViewController taskViewController推送到导航堆栈上 我的问题是,当我现在从taskViewController调用以下命令时,不会发生任何事情: detailViewController.detailItem = [NSString

这是我的第一篇帖子,所以请温柔一点

我在xcode中使用基本的基于分割视图的应用程序,但是已经对其进行了编辑,这样rootViewController就不会简单地更新detailViewController,而是将一个新的UITableViewController taskViewController推送到导航堆栈上

我的问题是,当我现在从taskViewController调用以下命令时,不会发生任何事情:

detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row];
如果我从rootViewController调用它,而不是将新的UITableView推送到堆栈上,它就会工作

以下是我在选择单元格时从rootViewController获得的代码:

- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    TaskViewController *taskViewController = [[TaskViewController alloc] init];

    taskViewController.title = [NSString stringWithFormat:@"Unit %d",indexPath.row];

    [self.navigationController pushViewController:taskViewController animated:YES];

    [taskViewController release];
}

我做错什么了吗?我是否在UISplitViewController的rootViewController中正确使用了导航控制器?

您的rootViewController可以访问detailViewController,因为它有一个引用。如果将新控制器推送到导航堆栈上,则不会自动了解DetailViewController

您是否在taskVC中记录了detailViewController以查看它是否有指针

您通常会在创建时这样设置:

 - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        TaskViewController *taskViewController = [[TaskViewController alloc] init];

        taskViewController.title = [NSString stringWithFormat:@"Unit %d",indexPath.row];

        taskViewController.detailViewController = self.detailViewController;

        [self.navigationController pushViewController:taskViewController animated:YES];

        [taskViewController release];
    }

好极了我只是假设UISplitViewController处理了所有这些。谢谢你,就VC的基本根和细节而言,确实如此,但在那之后,你就要依靠自己了——dw,这是你开始创业时的一个常见错误。我应该警告你,虽然我也有其他问题,但我会让你自己去旅行。NSLog是你的朋友。