【问题标题】:Cant find navigation controller to navigate another view controller找不到导航控制器来导航另一个视图控制器
【发布时间】:2015-07-06 09:42:33
【问题描述】:

我有一个自定义的UIPageViewController,其中包含 5 个UIViewControllers,现在我想从这 5 个UIViewController 之一导航,但我不能,因为在那些UIViewControllers 中没有UINavigationController。谁能建议我,我如何从这 5 个 UIViewControllers 导航到另一个 UIViewController

【问题讨论】:

  • 您可以通过这种方式从一个控制器导航到另一个控制器:- [self presentModalViewController:temp animated:YES];
  • 我认为您需要遵循“theappcodeblog.com/…”教程。您需要通过Embed -> Navigation Controller 将其设置为初始视图控制器来创建导航栏。或者按照教程手动创建导航栏
  • 使用pageviewcontroller导航,你可以推送viewcontroller

标签: ios objective-c uiviewcontroller uinavigationcontroller uipageviewcontroller


【解决方案1】:

您的代码 - [AppDelegate application:didFinishLaunchingWithOptions:] 可能看起来像这样(当然在检查您的跳过条件之后):

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc1 = [storyboard instantiateViewControllerWithIdentifier:@"MyAuth"]; //if you assigned this ID is storyboard
UIViewController *vc2 = [storyboard instantiateViewControllerWithIdentifier:@"Login"];  //if you assigned this ID is storyboard
UIViewController *vc3 = [storyboard instantiateViewControllerWithIdentifier:@"Details"];
NSArray *controllers = @[vc1, vc2, vc3];
UINavigationController *navController = (UINavigationController *)self.window.rootViewController;
[navController setViewControllers:controllers];

如果您将其粘贴到 - [AppDelegate application:didFinishLaunchingWithOptions:],您会发现它立即生效。

【讨论】:

    猜你喜欢
    • 2013-03-12
    • 2016-09-06
    • 1970-01-01
    • 2020-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多