2016-08-16 12 views
3

"このアプリケーションは、自動レイアウトエンジンをバックグラウンドスレッドから修正しています"というエラーを修正する方法を知りませんでした。どんな助けでも大歓迎です。"このアプリケーションは自動レイアウトエンジンを修正しています"エラー(Swift iOS)

this similar questionから概説したアプローチでは、dispatch_async(dispatch_get_main_qeueu())を使用しましたが、問題を解決していません。私はそれを間違って使用していますか?

デバッグから私はFirebaseの呼び出しがユーザパスワードをリセットすることが少なくとも問題の一部であることを断言しました。そのコードを省略すると、エラーはありません。

関連するコードと完全なエラーメッセージは以下の通りです:

//MARK: - Forgot Password Button Tapped 
    @IBAction func forgotPasswordButtonTapped(sender: AnyObject) { 

    let userEnteredEmail = emailTextField.text 

    //Have Firebase send email to reset password  
     dispatch_async(dispatch_get_main_queue(), { 

     FIRAuth.auth()?.sendPasswordResetWithEmail(userEnteredEmail!, completion: { error in 

      if error != nil { 

       //Tell user that the user name or password is incorrect. 
       let errorCode = error!.code 

       switch (errorCode) { 
        // Error code handling alerting user to issue. 
        } 
      } 
      else { 
       //Send user to the forgot password screen. 
       self.performSegueWithIdentifier("toForgotPasswordViewController", sender: self) 
      } 
     }) 
     }) 
    } 
} 

フル・エラーがスローさ:

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      0x000000010a87dd85 __exceptionPreprocess + 165 
1 libobjc.A.dylib      0x000000010c6a5deb objc_exception_throw + 48 
2 CoreFoundation      0x000000010a87dcbd +[NSException raise:format:] + 205 
3 Foundation       0x000000010adf8b6b _AssertAutolayoutOnMainThreadOnly + 79 
4 Foundation       0x000000010adf8a62 -[NSISEngine _optimizeWithoutRebuilding] + 49 
5 Foundation       0x000000010ac57c0f -[NSISEngine optimize] + 46 
6 Foundation       0x000000010ac5842d -[NSISEngine withBehaviors:performModifications:] + 245 
7 UIKit        0x000000010b9e6adb -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 58 
8 UIKit        0x000000010b9e761e -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 254 
9 UIKit        0x000000010b9e8333 -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 272 
10 UIKit        0x000000010b19ca96 -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 159 
11 UIKit        0x000000010b1ac980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703 
12 QuartzCore       0x0000000109e05c00 -[CALayer layoutSublayers] + 146 
13 QuartzCore       0x0000000109dfa08e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 
14 QuartzCore       0x0000000109df9f0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 
15 QuartzCore       0x0000000109dee3c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 
16 QuartzCore       0x0000000109e1c086 _ZN2CA11Transaction6commitEv + 486 
17 QuartzCore       0x0000000109e1c378 _ZN2CA11Transaction14release_threadEPv + 224 
18 libsystem_pthread.dylib    0x000000010d4d7387 _pthread_tsd_cleanup + 470 
19 libsystem_pthread.dylib    0x000000010d4d6f63 _pthread_exit + 117 
20 libsystem_pthread.dylib    0x000000010d4d5582 pthread_attr_getschedpolicy + 0 
21 libsystem_pthread.dylib    0x000000010d4d3341 start_wqthread + 13 
) 

任意のアイデアや考えをありがとう!

+2

はあなたがチェックした、FIRAuthかコールバックはメインスレッドにありますか? – mbutan

+0

ほとんど確かにそうではありません。 FIRAuthコールバックのメインスレッドに別のdispatch_asyncを実行します。 – par

+0

FIRAuthコールバックがメインスレッドに含まれているかどうかを具体的に教えてください。私はFirebaseとiOSで危険だと知っていますが、専門家はいません。他のdispatch_asyncがどこに記載されるべきかわからない。ありがとう。 – Ben

答えて

6

これを試してみてください:

FIRAuth.auth()?.sendPasswordResetWithEmail(userEnteredEmail!, completion: { error in 
    dispatch_async(dispatch_get_main_queue(), { 
    if error != nil { 

     //Tell user that the user name or password is incorrect. 
     let errorCode = error!.code 

     switch (errorCode) { 
     // Error code handling alerting user to issue. 
     } 
    } 
    else { 
     //Send user to the forgot password screen. 
     self.performSegueWithIdentifier("toForgotPasswordViewController", sender: self) 
    } 
    }) 
}) 
+0

はい!それが私の欠けていたものでした。ありがとうございました!!! – Ben

0

が問題を検出するために、シンボリックブレークポイントを試してみてください: - enter image description here

が続いてメインスレッドであなたのUIの更新コードを入れ

DispatchQueue.main.async {} 
関連する問題