简体   繁体   English

iOS更改视图控制器来自应用程序委托?

[英]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.

相关问题 IOS | 无法在应用委托中更改根视图 controller - IOS | Unable to change root view controller in app delegate 从 iOS 中的 App Delegate 调用当前视图 controller 中的方法 - Calling method in current view controller from App Delegate in iOS 来自应用程序委托的导航控制器中的iOS切换视图 - iOS switch view in a navigation controller from the app delegate iOS:导航到未直接与应用程序委托连接的视图控制器 - iOS: navigate to a view controller not directly connected from the app delegate 在位置发生重大更改时重新加载/刷新View Controller(来自App委托) - Reload/Refresh View Controller on Significant Location Change (from App Delegate) 使用选项卡控制器->导航控制器->视图层次结构显示来自应用程序委托的视图-iOS Swift - Present view from app delegate with a tabbar Controller-> Nav controller -> View Hierarchy - iOS Swift 使用ios中的自定义委托从另一个视图控制器更改一个视图控制器NSSdictonary的值 - Change value of one view controllers NSSdictonary from other view controller using custom delegate in ios ios:从应用程序委托访问导航控制器 - ios: Accessing a navigation controller from app delegate 从应用程序委托呈现视图控制器 - Present view controller from app delegate View Controller不在App Delegate中显示 - View Controller not presenting from App Delegate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM