This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.

更新UI的操作必须放在主线程里,否则可能会出错。
This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
Stack:(
0 CoreFoundation 0x1c6cce0f + 154
1 libobjc.A.dylib 0x1b92f077 objc_exception_throw + 38
2 CoreFoundation 0x1c6ccd3d + 0
3 Foundation 0x1d104d81 + 280
4 Foundation 0x1cf6fa25 + 40
5 UIKit 0x22063c59 + 108
6 UIKit 0x220639c3 + 514
7 UIKit 0x220639c3 + 514
8 UIKit 0x22064115 + 84
9 UIKit 0x220633bd + 128
10 UIKit 0x22063d75 + 162
11 UIKit 0x22064bef + 360
12 UIKit 0x21a67751 + 164
13 UIKit 0x21775df7 + 1364
14 QuartzCore 0x1f589841 + 126
15 QuartzCore 0x1f57d78f + 354
16 QuartzCore 0x1f57d61f + 16
17 QuartzCore 0x1f50e2c3 + 370
18 QuartzCore 0x1f52cbb5 + 564
19 QuartzCore 0x1f52d653 + 162
20 CoreFoundation 0x1c687f15 + 20
21 CoreFoundation 0x1c686191 + 282
22 CoreFoundation 0x1c5d5553 CFRunLoopRunSpecific + 518
23 CoreFoundation 0x1c5d5341 CFRunLoopRunInMode + 104
24 WebCore 0x207c2c83 + 426
25 libsystem_pthread.dylib 0x1bf29a27 + 216
26 libsystem_pthread.dylib 0x1bf2994d _pthread_start + 234
27 libsystem_pthread.dylib 0x1bf2749c thread_start + 8
)

解决办法:

dispatch_async(dispatch_get_main_queue()) {
// Do UI stuff here
}
或者

[NSOperationQueue mainQueue] addOperationWithBlock:^{
//Do UI stuff here
}];

你可能感兴趣的:(This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.)