如何通过使用一个Storyboard使用自定义Navigationcontroller中的AppDelegate [英] How to use custom Navigationcontroller in AppDelegate by using a Storyboard

查看:220
本文介绍了如何通过使用一个Storyboard使用自定义Navigationcontroller中的AppDelegate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've got a problem concerning Navigationcontroller in AppDelegate. I'm using a storyboard, which looks like this:

由于采用推送通知的结果,我已经得到了下面的函数在我的AppDelegate文件:

As a result of using Push notifications, i've got the following function in my AppDelegate File:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//...
}

在通知到达我想初始化详细信息视图 - 控制器,它需要一个ID作为参数。此ID是我的有效载荷的一部分,所以它是在present didReceiveRemoteNotification

When the notification arrives I want to initialize the "Detail View" - Controller which needs an ID as a parameter. This ID is part of my payload so it is present in didReceiveRemoteNotification.

我喜欢的follwing会:

I'd like to to the follwing:

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

detail.conversationID = theID; 

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

我在这一点上的问题是:我怎样才能得到导航控制器?我搜索了类似getNavigationControllerByIdentifier或类似这样的功能,但一无所获。因为导航栏是缺少那里,我不能直接实例的详细视图控制器。

My question at this point is: how can I get the navigation controller? I've searched for a function like "getNavigationControllerByIdentifier" or something like this, but found nothing. I can't instantiate the Detail View Controller directly because the navigationbar is missing there.

我希望你明白我的意思 - 如果你认为我的做法是完全地错误请指正; O)

I hope you understand what I mean - if you think my approach is completly wrong please correct me ;o)

只是另一个小资料:这不是对我很重要,在详细视图控制器后退按钮返回到表视图 - 它足够时,它链接到与按钮加载表视图

Just another small information: It's not important for me that the back button in the Detail View Controller goes back to the Table View - it's enough when it links to the controller with the button "Load Table View".

感谢您的帮助!

推荐答案

的UINavigationController 的UIViewController 子类,并能在故事板还可以指定一个标识符。

UINavigationController is a UIViewController subclass and can also be assigned an identifier in the storyboard.

使用 -instantiateViewControllerWithIdentifier:来创建的UINavigationController ,它的根视图控制器。您可能需要实例都在code中间控制器和修改导航控制器的 viewControllers 属性来设置相应的导航堆栈。当应用程序启动到详细信息视图通过这种方式,他们可以找到自己的方式回到好像他们手动推一路过关斩将通过该接口。

Use -instantiateViewControllerWithIdentifier: to create the UINavigationController and it's root view controller. You may need to instantiate all of the intermediate controllers in code and modify the navigation controller's viewControllers property to set up the appropriate navigation stack. This way when the app launches into the detail view, they can find their way back as if they had manually pushed all the way through via the interface.

这篇关于如何通过使用一个Storyboard使用自定义Navigationcontroller中的AppDelegate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆