当我切换回模拟器中的设置时,Xcode中显示错误。如果有人知道请通知我。提前致谢
GeoNet[2325:41287] This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(
0 CoreFoundation 0x00c5ba14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0071ce02 objc_exception_throw + 50
2 CoreFoundation 0x00c5b93d +[NSException raise:format:] + 141
3 Foundation 0x004ee74b _AssertAutolayoutOnMainThreadOnly + 96
4 Foundation 0x003164c1 -[NSISEngine optimize] + 67
5 Foundation 0x00316f84 -[NSISEngine withBehaviors:performModifications:] + 245
6 Foundation 0x0031a404 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
7 UIKit 0x01dd9b08 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 75
8 UIKit 0x01dda781 -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 278
9 UIKit 0x01aa48b8 -[UITableViewCellContentView updateConstraintsIfNeeded] + 185
10 UIKit 0x01ddb66c -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 372
11 UIKit 0x014a919a -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 173
12 UIKit 0x014a9929 -[UIView(Hierarchy) layoutSubviews] + 184
13 UIKit 0x014bb008 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
14 libobjc.A.dylib 0x00731059 -[NSObject performSelector:withObject:] + 70
15 QuartzCore 0x0603480a -[CALayer layoutSublayers] + 144
16 QuartzCore 0x060284ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
17 QuartzCore 0x06028352 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
18 QuartzCore 0x0601ae8b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
19 QuartzCore 0x0604ee03 _ZN2CA11Transaction6commitEv + 561
20 QuartzCore 0x0604f1ab _ZN2CA11Transaction14release_threadEPv + 289
21 libsystem_pthread.dylib 0x0308d2f7 _pthread_tsd_cleanup + 93
22 libsystem_pthread.dylib 0x0308d051 _pthread_exit + 108
23 libsystem_pthread.dylib 0x0308d734 pthread_get_stackaddr_np + 0
24 libsystem_pthread.dylib 0x0308ae0e start_wqthread + 30
)
答案 0 :(得分:1)
这是从iOS 9开始发生的,在早期版本中,您的代码可以正常工作。这是因为,您的某些函数必须在后台线程上执行,并在视图加载后尝试更改视图的外观。因此,您必须将该函数放在主线程上并异步加载它。请分享您正在尝试加载的ViewController的代码,以获得更具体的答案。
dispatch_async(dispatch_get_main_queue(), ^{
// your code here
})
答案 1 :(得分:0)
在我的OS X中使用swift遇到了这个错误:“这个应用程序正在从后台线程修改自动布局引擎,这可能导致引擎损坏和奇怪的崩溃。这将导致未来版本中的异常。”
请参阅this链接,您可以找到解决方案。