[英]iOS change view controller from the app delegate?
Above is the storyboard for my chat app. 以上是我的聊天应用的故事板。 What you'r not seeing to the left before the
Navigation Controller
is a simple login view. 在
Navigation Controller
是一个简单的登录视图之前,你没有看到左边的内容。 The Storyboard Segue identifier to the Navigation Controller
is mainViewC
. Navigation Controller
的Storyboard Segue标识符是mainViewC
。
What i want to do is to take the user to the Conv View Controller
when a push notification
is pressed. 我想要做的是在按下
push notification
时将用户带到Conv View Controller
。
This is what i've got so far: 这是我到目前为止所得到的:
// AppDelegate.h
@property (strong, nonatomic) ConvViewController *convViewController;
// AppDelegate.m
self.window.rootViewController = self.convViewController;
This takes me to the correct view but the view is black. 这会将我带到正确的视图,但视图是黑色的。 Im guessing this has something to do with the
Navigiation Controller
not being loaded correctly.. 我猜测这与
Navigiation Controller
没有正确加载有关。
Any ideas? 有任何想法吗?
What you'll need to do is access the view controller from the story board. 您需要做的是从故事板访问视图控制器。 First go to the VC you wish to bring users to and give it a Storyboard ID.
首先转到您希望带给用户的VC并为其提供Storyboard ID。 Then in your app delegate you would write.
然后在你的app委托中你会写。
self.window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"identifier"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.