ios - iOS 12 SDK 需要自动布局?
问题描述
我使用 iOS SDK 12 在 Xcode 10 中启动了一个新项目。我选择了 Master-Detail App 模板。我可以从一开始就运行该应用程序,而无需对项目进行任何更改并且它可以工作。但是,当我所做的唯一更改是关闭 Main.storyboard 中的自动布局时,应用程序在主视图中选择项目并将其发送到详细视图时崩溃。即使我所做的唯一更改是关闭自动布局。
iOS 12 SDK 是否需要自动布局?
在 Xcode 9 中,在 Master-Detail 应用程序模板中关闭 Autolayout 不会导致此崩溃。
任何帮助将不胜感激,我知道我应该过渡到自动布局而不是手动执行所有操作,但我已经到了那里。
下面是吐出的错误。
2018-10-08 11:16:02.968981-0400 Trial2[1100:19064] -[DetailViewController topViewController]: unrecognized selector sent to instance 0x7fbb3652b350
2018-10-08 11:16:02.981283-0400 Trial2[1100:19064] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailViewController topViewController]: unrecognized selector sent to instance 0x7fbb3652b350'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f2ce29b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010df3f735 objc_exception_throw + 48
2 CoreFoundation 0x000000010f2ecfa4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKitCore 0x0000000111cac163 -[UIResponder doesNotRecognizeSelector:] + 287
4 CoreFoundation 0x000000010f2d2fb6 ___forwarding___ + 1446
5 CoreFoundation 0x000000010f2d4e88 _CF_forwarding_prep_0 + 120
6 Trial2 0x000000010d61d049 -[MasterViewController prepareForSegue:sender:] + 361
7 UIKitCore 0x0000000111dc05c7 -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 182
8 UIKitCore 0x0000000111dc04e3 -[UIStoryboardSegueTemplate _perform:] + 82
9 UIKitCore 0x0000000111dc07a5 -[UIStoryboardSegueTemplate perform:] + 157
10 UIKitCore 0x0000000111e19cbb -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1703
11 UIKitCore 0x0000000111e19f44 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 344
12 UIKitCore 0x00000001118d097e _runAfterCACommitDeferredBlocks + 318
13 UIKitCore 0x00000001118bf424 _cleanUpAfterCAFlushAndRunDeferredBlocks + 384
14 UIKitCore 0x00000001118ee870 _afterCACommitHandler + 135
15 CoreFoundation 0x000000010f231037 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
16 CoreFoundation 0x000000010f22b4ce __CFRunLoopDoObservers + 430
17 CoreFoundation 0x000000010f22bb61 __CFRunLoopRun + 1537
18 CoreFoundation 0x000000010f22b221 CFRunLoopRunSpecific + 625
19 GraphicsServices 0x00000001175f91dd GSEventRunModal + 62
20 UIKitCore 0x00000001118c5115 UIApplicationMain + 140
21 Trial2 0x000000010d61bef0 main + 112
22 libdyld.dylib 0x000000011099b551 start + 1
23 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
斯蒂芬达灵顿回答后更新
第一张图片是创建项目时的初始故事板。第二张图片是关闭自动布局时情节提要如何更改。
解决方案
这与自动布局无关。仍然完全支持“手动”布局;自动布局只是 Apple 的首选方法。
相反,错误出现在堆栈跟踪的第一行:
-[DetailViewController topViewController]: unrecognized selector sent to instance 0x7fbb3652b350
看起来 aUINavigationController
已在某处被删除,topViewController
而是被发送到视图控制器。
推荐阅读
- azure - 如何正确将 ASPNETCORE_ENV 设置为非开发值?
- ruby - 即使捆绑安装运行良好,gem 中的加载错误
- sql-server - 对于具有 IDENTITY 列的表上的 INSTEAD OF 触发器,如何处理 IDENTITY_INSERT?
- c# - TcpListener 在 UWP 应用程序上不起作用
- r - 为什么 R 中的 mtcars 数据集中没有汽车名称的列名?
- haskell - Haskell、Ocaml、Javascript 中的语句与表达式
- angularjs - AngularJS ui-router - 生成
返回当前网址 - java - box2d 在 libgdx 上精灵的不同位置
- android - Android App崩溃,无法解决问题
- android - 导航架构组件 - 对话框片段