我正在尝试在我的 iOS 项目中使用导航控制器。这是我的 AppDelegate 类的设置:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Generate RootViewController (some auto-layout stuff is going on here)
MyLayoutDescriptionGeneratorClass *generator = [MyLayoutDescriptionGeneratorClass new];
MyViewControllerClass *vc = [generator generateViewController];
self.navController = [[UINavigationController alloc] initWithRootViewController:vc];
[self.window setRootViewController:self.navController];
[self.window makeKeyAndVisible];
return YES;
}
我的viewDidLoad
视图控制器看起来像这样:
-(void)viewDidLoad{
[super viewDidLoad];
// Generate all subviews and their constraints
self.view = [MyObjectManagerClass viewForParentViewDescription:_parentViewDescription];
self.title = @"Hello";
}
当我构建并运行时,会显示导航栏,并且它的标题设置为Hello
- 不幸的是,视图控制器视图没有显示。
如果我像这样取出导航控制器
[self.window setRootViewController:self.navController];
一切都很好。任何人都可以帮助我吗?