找不到导航控制器来导航另一个视图控制器
Cant find navigation controller to navigate another view controller
我有一个包含 5 个 UIViewControllers
的自定义 UIPageViewController
,现在我想从这 5 个 UIViewController
之一导航,但我不能,因为在那些 UIViewControllers
没有UINavigationController
。谁能建议我,如何从这 5 个 UIViewControllers
中的一个导航到其他 UIViewController
?
您的代码 - [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:]
,您会发现它会立即生效。
我有一个包含 5 个 UIViewControllers
的自定义 UIPageViewController
,现在我想从这 5 个 UIViewController
之一导航,但我不能,因为在那些 UIViewControllers
没有UINavigationController
。谁能建议我,如何从这 5 个 UIViewControllers
中的一个导航到其他 UIViewController
?
您的代码 - [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:]
,您会发现它会立即生效。