启动模态视图控制器时导航控制器视图被破坏(升级最新的 xcode/ios 5 后)
我叫 Luca,在升级 ios 5 的 XCode 后,我的应用程序遇到了问题。我真的可以找到解决方案,所以我希望有人可以帮助我。
我的软件是一个基于窗口的应用程序,它使用导航控制器和工具栏项。导航控制器在 mainWindow.xib 中连接到应用程序委托导航控制器属性 (IBOutlet
)。导航控制器使用根视图控制器进行初始化,我将其称为“启动视图控制器”(这是在 IB 中完成的)。该应用程序的状态栏在顶部可见。 在我的应用程序委托中,我这样做:
[application setStatusBarStyle:UIStatusBarStyleBlackOpaque];
application.statusBarHidden = NO;
self.window.rootViewController = navigationController;
[window makeKeyAndVisible];
[startingViewController onLaunchApp];
应用程序完成加载后,我尝试使用模态视图控制器呈现另一个视图。通过这样做,模态视图控制器出现在根视图控制器(启动视图控制器)中,
[self presentModalViewController:'another view' animated:YES];
这是我的问题。一旦我关闭模态视图控制器,导航控制器就会移动到主窗口的最顶部,并拉起根视图控制器。导航栏的一部分位于状态栏后面(20 像素),其他 20 像素的空白区域保留在根视图控制器的底部。因此,我的视图变得完全混乱,解决它的唯一方法是横向旋转设备,然后再返回纵向。在这些操作之后,整个视图的堆栈都正常,如果模式视图控制器再次出现并关闭,一切都会正常工作。换句话说,这个问题仅在模态视图控制器第一次被关闭时发生。
我已经使用所有模拟器版本测试了该应用程序,除了最新的 5.0 之外,它们都可以正常工作。
我花了过去 6 个小时阅读文档、帖子并尝试修复该应用程序,但没有成功。
如果有人可以帮助我或给我任何提示,我将不胜感激。
预先非常感谢您。
My name is Luca and I am experiencing an issue in my app after upgrading my XCode for ios 5. I really can find a solution to that, so I hope that someone can help me.
My software is a window-based
application that uses a navigation controller and a toolbar item. The navigation controller is connected in mainWindow.xib to the application delegate navigation controller property (IBOutlet
). The navigation controller init with a root view controller that I call 'starting view controller' (this is done in IB). The app has the status bar visible on top.
In my application delegate I do:
[application setStatusBarStyle:UIStatusBarStyleBlackOpaque];
application.statusBarHidden = NO;
self.window.rootViewController = navigationController;
[window makeKeyAndVisible];
[startingViewController onLaunchApp];
Once the app has finished loading I try to present another view using the Modal View Controller. The Modal View Controller is presented in the root view controller (starting view controller) by doing
[self presentModalViewController:'another view' animated:YES];
Here comes my issue. Once I dismiss the modal view controller, the navigation controller moves on the very top of the main window pulling up with it the root view controller. Part of the navigation bar lies behind the status bar (20 px) and other 20 px of white space are left at the bottom of the root view controller. Therefore my view becomes completely messed up and the only way to fix it is to rotate the device in landscape and then back in portrait orientation. After these operations the whole views' stack is ok and if the modal view controller is presented and dismissed again everything works just fine. In other words, this problem occurs only the first time the modal view controller is dismissed.
I have tested the app with all the simulator versions and they all work correctly except for the latest 5.0.
I spent the last 6 hours reading documentation, posts and trying to fix the app, but no luck.
I would appreciate a lot if someone could help me or give me any hint.
Thank you very much in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您还没有以这种方式实现它,请尝试从根视图控制器中关闭模式视图控制器。
If you haven't implemented it this way, try to dismiss modal view controller from the root view controller.