【发布时间】:2013-03-24 18:59:33
【问题描述】:
在 AppDelegate 中的方法 application:didFinishLaunchingWithOptions 中,我启动了一个视图控制器并添加到成为窗口根视图控制器的导航视图控制器。 因为我的 iPad 应用程序只是水平方向,所以我的所有视图控制器都是为横向制作的。
代码如下:
self.myViewController = [[MyViewController alloc] init];
self.myNavigationController = [[MyNavigationController alloc] initWithRootViewController: self.myViewController];
self.window.rootViewController = self.myNavigationController;
[self.window makeKeyAndVisible];
return YES;
当我在“self.window.rootViewController = self.myNavigationController;”上设置断点时行并在控制台中调用以显示视图详细信息,我得到以下信息: $0 = 0x0c89d010 >
我读到的矩形是方向模式(1024 宽和 748 高)
“return YES;”上的下一个断点给我看这个: $1 = 0x0c89d010 >
复制一个对象(据我所知)并改变方向(768宽和1004高)
这仅在 iOS5 中发生,但 iOS6 可以正常工作
我应该知道 MakeKeyAndVisible 方法是否存在任何已知问题? 或者可能是我不了解 makeKeyAndVisible 的工作原理
【问题讨论】:
-
你在为iOS5实现定位方法吗?
-
这与
makeKeyAndVisible无关 - iOS 5 和 iOS 6 之间处理方向的方式发生了变化 -
我正在我的视图控制器中实现 shouldAutorotateToInterfaceOrientation: 方法以确保它是横向的。
-
你需要实现自定义的NavigationController,使用navigationcontroller你所有的定位方法都会被打乱。
-
你能展示
shouldAutoRotateToInterfaceOrientation:的实现吗?这个方法会被调用吗?
标签: ios objective-c ios5 uiviewcontroller appdelegate