如何更新splitViewController中的detailView?

use*_*477 2 cocoa-touch objective-c uisplitview uisplitviewcontroller

我正在尝试更新splitViewController中的detailView.这是我尝试的:

//Get the application delegate
AppDelegate *delegate = [[UIApplication sharedApplication] delegate];

//Get the masterViewController
MasterViewController *master = [delegate.splitViewController.viewControllers objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)

到目前为止,这似乎工作正常.然后我尝试通过执行以下操作更新detailViewController中的标签:

master.detailViewController.myLabel.text = @"someText";
Run Code Online (Sandbox Code Playgroud)

但这不起作用.

那么如何正确访问detailView中的出口?

感谢帮助.

小智 5

定义DetailViewController; 在您的示例中,detailViewController是:

DetailViewController*detailViewController = [delegate.splitViewController.viewcontrollers objectAtIndex:1];