简体   繁体   English

如何以编程方式显示具有情节提要中定义的导航控制器和标签栏控制器的控制器?

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

相关问题 将xcode4中的导航和标签栏控制器与情节提要结合在一起 - combine navigation and tabbar controller in xcode4 with storyboard 如何在以编程方式使用导航控制器设置动画的情节提要中设置根视图控制器 - How to set root view controller in storyboard animated with navigation controller programmatically 如何在 ios siwft 中以编程方式将 storyboard 视图控制器加载到标签栏 controller 中? - How to load storyboard viewcontroller into programmatically tabbar controller in ios siwft? 如何将Navigation Controller嵌入到选项卡控制器中 - How to embed in Navigation Controller to a tabbar controller 导航 Controller 在使用 TabBar 控制器时不显示标题(以编程方式) - Navigation Controller doesn't show the title while working with TabBar Controller(Programmatically) 将导航控制器实现到标签栏控制器中 - Implement a navigation controller into a tabbar controller 导航控制器干扰TabBar控制器 - Navigation Controller interfering with TabBar Controller 将导航控制器放在标签栏控制器中 - Put a navigation controller in a tabbar controller 故事板 - 以编程方式隐藏导航控制器的顶部栏 - Storyboard - Hiding top bar of navigation controller programmatically TabBar 和导航控制器 - TabBar and Navigation Controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM