2015-12-02 24 views
1

我不明白它來自哪裏...我不知道它是否它是鏈接的,但我將一個「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... 

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

+0

您正在從後臺線程操縱UI元素。你只應該從主線程操縱UI元素。 –

+0

您需要查看您正在執行異步操作的位置 - 您獲得回調的位置;如果這些位於後臺線程上,則需要在主隊列上調度UI更新 – Paulw11

+0

您是否有任何關閉,試圖更改視圖的佈局或僅設置UIlabel中的文本? – abarbier

回答

4

您必須切換到主線程才能調用用戶界面代碼。最簡單的方法是dispatch_async(dispatch_get_main_queue()

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

它完美的作品。謝謝 :) – Claudio

相關問題