UISplitViewController 与 NavigationControllers(包括示例代码)
查看此问题的最简单方法是在此处运行示例项目:
基本上,它是一个 uisplitviewcontroller,可以在 2 个详细视图之间切换,这两个视图都是导航控制器。
问题是它崩溃并出现以下错误:
MultipleDetailViews[8531:207] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“无法从没有窗户。'
如果您在纵向中使用该应用程序,并且从第一个控制器导航(仍然是纵向)到第二个控制器,到第一个控制器,再到第二个控制器,然后使用弹出控制器崩溃,它会因此错误而崩溃。
阻止崩溃的一种方法是停止延迟加载导航控制器并每次都重新加载它们,但这不是我正在制作的应用程序的选项。
任何想法都可能和我坠入爱河。
The easiest way to see this problem will be to run the sample project here:
Basically, It's a uisplitviewcontroller which can be switched between 2 detail views, both of which are navigation controllers.
The problem is that it crashes with the following error:
MultipleDetailViews[8531:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Popovers cannot be presented from a view which does not have a window.'
It crashes with this error if you use the app in PORTRAIT and you navigate (still in portrait) from the first controller, to the second, to the first, to the second, and then boom CRASH using the popover controller.
One way to stop the crash is to stop lazy loading the navigation controllers and to load them fresh everytime but this isn't an option for the app I'm making.
Any ideas and I may fall in love.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在导致崩溃的行之前使用 if (self.view.window != nil) 。
Try using if (self.view.window != nil) just before the line that's causing the crash.