![](/img/trans.png)
[英]UITapGestureRecognizer not working inside of custom class (that's not a view controller)
[英]How to assign a view controller as UINavigationController's first item inside a custom class but not in AppDelegate?
我想创建一个位于navigation
层次结构顶部的视图控制器HomePageViewController
。 但我不想在AppDelegate
创建它。 我有另一个viewcontroller
, MainViewController
,它分配和inits HomePageViewController
。
所以,首先我在AppDelegate
创建MainViewController
,然后在MainViewController
创建HomePageViewController
。
提前致谢。
创建导航控制器- (id)initWithRootViewController:(UIViewController *)rootViewController
,其中rootViewController
是你的HomePageViewController
当前导航控制器- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
试试这个代码:
HomePageViewController *controller=[HomePageViewController alloc] init];
UINavigationController *navigationController=[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navigationController animated:YES completion:Nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.