为 ipad 3.2 设置 rootViewController 不起作用
我做了一个简单的基于导航的应用程序。 它在 iphone 上工作得很好,但在 ipad 3.2 模拟器和设备上不起作用。
在 applicationdidfinish 事件中;
MainViewController *viewController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
[self.navigationController pushViewController:viewController animated:NO];
self.window.rootViewController = self.navigationController;
[viewController release];
它对这一行说:
self.window.rootViewController = self.navigationController;
[UIWindow setRootViewController:]:无法识别的选择器发送到实例0x4c22dd0
但它适用于ipad 4.2及更高版本。
ipad 3.2 该如何解决这个问题?
i did a simple navigationbased app.
it works on iphone very well, but it doesnt work on ipad 3.2 simulator and device.
in applicationdidfinish event;
MainViewController *viewController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
[self.navigationController pushViewController:viewController animated:NO];
self.window.rootViewController = self.navigationController;
[viewController release];
it says for this line:
self.window.rootViewController = self.navigationController;
[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x4c22dd0
but it works on ipad 4.2 and over.
how can i solve it for ipad 3.2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UIWindow 在 iOS 中没有 rootViewController 属性< 4.0。因此,您需要检查版本(google 一下),然后根据您的用户运行的版本设置 rootViewController,或将 navigationController 的
view
作为子视图添加到窗口中,如下所示。 :快速编辑:要检查是否可以使用 rootViewController 属性,可以检查
[self.window respondsToSelector:@selector(setRootViewController)]
返回 TRUE 还是 FALSE。UIWindow did not have a rootViewController property in iOS < 4.0. Therefore, you will need to check the version (google it) and then either set the rootViewController, or add the navigationController's
view
as a subview to the window as below, based on what version your user is running.:quick edit: to check if you can use the rootViewController property, you can check if
[self.window respondsToSelector:@selector(setRootViewController)]
returns TRUE or FALSE.正确的方法是(不要忘记“:”!):
The correct way is (don't forget ":"!):