“这个应用程序正在从后台线程修改自动布局引擎,这可能导致引擎损坏和怪异的崩溃…”

我不明白它可能来自哪里……我不知道它是否链接,但我从一个视图传递一个“activityIndi​​cator”和一个“statusLabel”到另一个,是这个问题吗?

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 0x246cf883 <redacted> + 150 1 libobjc.A.dylib 0x35dcedff objc_exception_throw + 38 2 CoreFoundation 0x246cf7b1 <redacted> + 0 3 Foundation 0x2556be63 <redacted> + 170 4 Foundation 0x25411ba7 <redacted> + 38 5 UIKit 0x288e3aa9 <redacted> + 52 6 UIKit 0x288e4487 <redacted> + 222 7 UIKit 0x28fbcfa5 <redacted> + 288 8 UIKit 0x28ad5fa9 <redacted> + 148 9 UIKit 0x287dd6bb <redacted> + 694 10 QuartzCore 0x280a967d <redacted> + 128 11 QuartzCore 0x280a4d79 <redacted> + 352 12 QuartzCore 0x280a4c09 <redacted> + 16 13 QuartzCore 0x280a4129 <redacted> + 368 14 QuartzCore 0x280a3deb <redacted> + 590 15 QuartzCore 0x280d1777 <redacted> + 310 16 libsystem_pthread.dylib 0x36666921 <redacted> + 508 17 libsystem_pthread.dylib 0x36666523 <redacted> + 86 18 libsystem_pthread.dylib 0x36667499 pthread_exit + 28 19 Foundation 0x253e9787 <redacted> + 10 20 Foundation 0x254a481f <redacted> + 1178 21 libsystem_pthread.dylib 0x36667c93 <redacted> + 138 22 libsystem_pthread.dylib 0x36667c07 _pthread_start + 110 23 libsystem_pthread.dylib 0x36665a24 thread_start + 8 ) 2015-12-02 11:35:03.138 QRCodeReader[735:277009] 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 0x246cf883 <redacted> + 150 1 libobjc.A.dylib 0x35dcedff objc_exception_throw + 38 2 CoreFoundation 0x246cf7b1 <redacted> + 0 3 Foundation 0x2556be63 <redacted> + 170 4 Foundation 0x25411ba7 <redacted> + 38 5 UIKit 0x288e3aa9 <redacted> + 52 6 UIKit 0x28fbc9d9 <redacted> + 132 7 UIKit 0x288e478b <redacted> + 86 8 Foundation 0x25411c81 <redacted> + 256 9 UIKit 0x288e3aa9 <redacted> + 52 10 UIKit 0x288e4487 <redacted> + 222 11 UIKit 0x28fbcfa5 <redacted> + 288 12 UIKit 0x28ad5fa9 <redacted> + 148 13 UIKit 0x287dd6bb <redacted> + 694 14 QuartzCore 0x280a967d <redacted> + 128 15 QuartzCore 0x280a4d79 <redacted> + 352 16 QuartzCore 0x280a4c09 <redacted> + 16 17 QuartzCore 0x280a4129 <redacted> + 368 18 QuartzCore 0x280a3deb <redacted> + 590 19 QuartzCore 0x280d1777 <redacted> + 310 20 libsystem_pthread.dylib 0x36666921 <redacted> + 508 21 libsystem_pthread.dylib 0x36666523 <redacted> + 86 22 libsystem_pthread.dylib 0x36667499 pthread_exit + 28 23 Foundation 0x253e9787 <redacted> + 10 24 Foundation 0x254a481f <redacted> + 1178 25 libsystem_pthread.dylib 0x36667c93 <redacted> + 138 26 libsystem_pthread.dylib 0x36667c07 _pthread_start + 110 27 libsystem_pthread.dylib 0x36665a24 thread_start + 8 ) 2015-12-02 11:35:03.150 QRCodeReader[735:277009] 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 0x246cf883 <redacted> + 150 1 libobjc.A.dylib 0x35dcedff objc_exception_throw + 38 2 CoreFoundation 0x246cf7b1 <redacted> + 0 3 Foundation 0x2556be63 <redacted> + 170 4 Foundation 0x254160ef <redacted> + 38 5 Foundation 0x25411ceb <redacted> + 362 6 UIKit 0x288e3aa9 <redacted> + 52 7 UIKit 0x288e4487 <redacted> + 222 8 UIKit 0x28fbcfa5 <redacted> + 288 9 UIKit 0x28ad5fa9 <redacted> + 148 10 UIKit 0x287dd6bb <redacted> + 694 11 QuartzCore 0x280a967d <redacted> + 128 12 QuartzCore 0x280a4d79 <redacted> + 352 13 QuartzCore 0x280a4c09 <redacted> + 16 14 QuartzCore 0x280a4129 <redacted> + 368 15 QuartzCore 0x280a3deb <redacted> + 590 16 QuartzCore 0x280d1777 <redacted> + 310 17 libsystem_pthread.dylib 0x36666921 <redacted> + 508 18 libsystem_pthread.dylib 0x36666523 <redacted> + 86 19 libsystem_pthread.dylib 0x36667499 pthread_exit + 28 20 Foundation 0x253e9787 <redacted> + 10 21 Foundation 0x254a481f <redacted> + 1178 22 libsystem_pthread.dylib 0x36667c93 <redacted> + 138 23 libsystem_pthread.dylib 0x36667c07 _pthread_start + 110 24 libsystem_pthread.dylib 0x36665a24 thread_start + 8 ) 

更确切地说:在第一个类中,我传递了activityIndi​​cator和statusLabel:

  [DataManagementObj WebServiceLogin: activityIndicator withLabel:statusLabel]; 

在正在等待响应服务器完成的第二个类中:

  -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"connectionDidFinishLoading"); // OTHER CODE HERE TO HANDLE THE RESPONSE.... NSLog(@"connection url : %@", connection.currentRequest.URL); NSLog(@"connection url : %@", [NSURL URLWithString:get_device_list_from_retailer_WS]); if ([connection.currentRequest.URL isEqual: [NSURL URLWithString:login_WS]]) { NSError* error; NSDictionary* response = [NSJSONSerialization JSONObjectWithData:receivedData options:kNilOptions error:&error]; NSLog(@"%@",[response objectForKey:@"key"]); int key = [[response objectForKey:@"key"] integerValue]; [self updateUser:key]; ======>[self stopSynchronizationAnimation]; } else if ([connection.currentRequest.URL isEqual: [NSURL URLWithString:get_retailer_list_from_wholesaler_WS]]) { NSError* error; NSDictionary* response = [NSJSONSerialization JSONObjectWithData:receivedData options:kNilOptions error:&error]; [self updateRetailerList: response]; ======>[self stopSynchronizationAnimation]; } else if ([connection.currentRequest.URL isEqual: [NSURL URLWithString:get_device_list_from_wholesaler_WS]]) { NSError* error; NSDictionary* response = [NSJSONSerialization JSONObjectWithData:receivedData options:kNilOptions error:&error]; [self update3TablesList: response]; ======>[self stopSynchronizationAnimation]; etc... 

如果有人有任何想法? 非常感谢。

您必须切换到主线程才能调用用户界面代码。 最简单的方法是dispatch_async(dispatch_get_main_queue()

 dispatch_async(dispatch_get_main_queue(), ^(){ [self stopSynchronizationAnimation]; // reload data on collection view or table view });