[英]How to programmatically show a controller that has a navigation controller and tabbar controller as defined in a storyboard?
I'd like to show the tableview controller embedded in the navigation controller from the app delegate. 我想显示来自应用程序委托的导航控制器中嵌入的tableview控制器。
The reason I need to do this is I'm building a wrapper over an api, so to login I direct users to a relevant webpage where they can login to grant my app access to their credentials, then they are sent to a relevant url end point which triggers my app. 我需要执行此操作的原因是我正在通过api构建包装程序,因此要登录,我会将用户定向到相关的网页,他们可以登录以授予我的应用访问其凭据的权限,然后将其发送到相关的网址末尾点触发我的应用。 At this point I want to load the tableviewcontroller in the navigation and tabbarcontroller.
此时,我想在导航和tabbarcontroller中加载tableviewcontroller。
Is it possible to define multiple entry points on storyboards? 是否可以在情节提要板上定义多个入口点?
A screenshot of my current storyboard configuration is shown here: https://www.dropbox.com/s/6wfo5werrs6vwy1/Screenshot%202014-10-09%2008.43.15.png?dl=0 我当前的故事板配置的屏幕截图显示在这里: https : //www.dropbox.com/s/6wfo5werrs6vwy1/Screenshot%202014-10-09%2008.43.15.png?dl=0
You cannot define multiple entry points on storyboards. 您不能在情节提要板上定义多个入口点。 To achieve this, you should use
[UIStoryboard instantiateViewControllerWithIdentifier:]
and set the view controller to root view controller in your app delegate based on your condition. 为此,您应该使用
[UIStoryboard instantiateViewControllerWithIdentifier:]
并根据您的情况将视图控制器设置为应用程序委托中的根视图控制器。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *identifier
if (/* path A */){
identifier = @"vc1";
} else {
identifier = @"vc2";
}
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:identifier];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.