gpt4 book ai didi

iphone - 为什么 Xcode 4 Navigation Based App 需要 "window.rootViewController = self.navigationController"?

转载 作者:可可西里 更新时间:2023-11-01 05:24:49 24 4
gpt4 key购买 nike

为什么 didFinishLaunchingWithOptions 方法中需要以下行?

self.window.rootViewController = self.navigationController;

也就是说,注意在 Interface Builder 中,在 MainWindow XIB 中,导航 Controller 及其层次结构中的导航栏和 RootViewController 已经存在。

整个方法的副本供引用:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the navigation controller's view to the window and display.
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}

最佳答案

在 MainWindow.xib 中还有一件事您还没有完成:将导航 Controller 的 View 添加到窗口。

线

self.window.rootViewController = self.navigationController;

就是这样做的。替代方案(以及我们在 iOS 3 中编写的内容)是:

[self.window addSubview:self.navigationController.view];

关于iphone - 为什么 Xcode 4 Navigation Based App 需要 "window.rootViewController = self.navigationController"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5763978/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com