Xcode 如何使用脚本在AppDelegate中使用自定义Navigationcontroller

Xcode 如何使用脚本在AppDelegate中使用自定义Navigationcontroller,xcode,uinavigationcontroller,apple-push-notifications,xcode-storyboard,Xcode,Uinavigationcontroller,Apple Push Notifications,Xcode Storyboard,我在AppDelegate中遇到一个有关Navigationcontroller的问题。我正在使用一个故事板,它看起来像这样: 由于使用推送通知,我的AppDelegate文件中有以下函数: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { //... } 当通知到达时,我想初始化“详细视图”-需要ID作为参数的控制器。此ID是我的有

我在AppDelegate中遇到一个有关Navigationcontroller的问题。我正在使用一个故事板,它看起来像这样:

由于使用推送通知,我的AppDelegate文件中有以下函数:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//...
}
当通知到达时,我想初始化“详细视图”-需要ID作为参数的控制器。此ID是我的有效负载的一部分,因此它出现在
didReceiveRemoteNotification

我想谈谈以下几点:

DetailView *detail = [storyboard instantiateViewControllerWithIdentifier:@"detail"];

detail.conversationID = theID; 

[self.navigationController pushViewController:detail animated:YES];
我现在的问题是:如何获得导航控制器?我搜索了“getNavigationControllerByIdentifier”之类的函数,但什么也没找到。我无法直接实例化详细视图控制器,因为那里缺少导航栏

我希望你理解我的意思——如果你认为我的方法完全错误,请纠正我;o)

还有一个小信息:对于我来说,细节视图控制器中的“后退”按钮返回到表视图并不重要——当它使用“加载表视图”按钮链接到控制器时就足够了


谢谢你的帮助

UINavigationController
是一个
UIViewController
子类,也可以在情节提要中分配一个标识符


使用
-instantialeviewcontrollerwhidentifier:
创建
UINavigationController
及其根视图控制器。您可能需要在代码中实例化所有中间控制器,并修改导航控制器的
viewControllers
属性以设置适当的导航堆栈。这样,当应用程序启动进入详细视图时,他们可以找到返回的路径,就好像他们已经通过界面手动推送了所有路径一样。

您可以在窗口对象上使用
rootViewController

UIViewController *rootViewController = self.window.rootViewController;
// You now have in rootViewController the view with your "Hello world" label and go button.

// Get the navigation controller of this view controller with:
UINavigationController *navigationController = rootViewController.navigationController;

// You can now use it to push your next view controller:
DetailViewController *detail = [navigationController.storyboard instantiateViewControllerWithIdentifier:@"detail"];
detail.conversationID = theID; 
[navigationController pushViewController:detailViewController animated:YES];

非常感谢。现在一切都清楚了,而且有效了:-)(赏金只在10小时内有效,所以别担心;o)