应用程序在viewDidDisappear

时间:2018-05-22 09:37:03

标签: ios swift crash

只有在使用iOS 10.2的5,5s和SE型号上才会发生非常奇怪的崩溃。 Firebase表示100%的崩溃发生在后台。

我能够准确地重现崩溃的堆栈(但不是模拟器上的崩溃本身),并且只知道当用户退出应用程序时它会发生。似乎没有其他的viewDidDisappear代码在真正崩溃时调用,因为在这种情况下堆栈会发生变化。

实际上,崩溃报告中提到的那条直线是在  super.viewDidDisappear(动画),它是空白的......

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)

        self.keyboardAvoiding.endAvoiding()
    }

KeyboardAvoiding

 func endAvoiding()
{
    self.avoiding = false

    // Update view frame
    updateConstraint(nil)
}


   private func updateConstraint(_ keyboardFrame: CGRect?, animationDuration: TimeInterval? = 0.0)
    {
        // Disable animation
        let state = UIView.areAnimationsEnabled
        UIView.setAnimationsEnabled(false)

        // Force to recalculate view frame if needed (without animation)
        self.view.superview?.layoutIfNeeded()

        // Restore previous animation state
        UIView.setAnimationsEnabled(state)

        if let keyboardFrame = keyboardFrame
        {
            // Decrease view frame
            self.constraint.constant = keyboardFrame.height
        }
        else {
            // Reset bottom constraint to initial value
            self.constraint.constant = self.initialConstraintConstant
        }

        // Layout superview
        UIView.animate(withDuration: animationDuration ?? 0.0, animations: {
            self.view.superview?.layoutIfNeeded()
            if let keyboardAvoidingScrollView = self.view.firstViewOfClass(TPKeyboardAvoidingScrollView.self)
            {
                // Scroll to active text field if scroll view frame changed
                keyboardAvoidingScrollView.scrollToActiveTextField()
            }
        })

    }

以下是崩溃报告:

Hardware Model:      iPhone6,2
Code Type:       ARM-64
Parent Process:  ??? [1]

OS Version:      iPhone OS 10.2 (14C92)

Exception Type:  SIGTRAP
Exception Codes: #0 at 0x100255178
Crashed Thread:  0

Application Specific Information:
Selector name found in current argument registers: release

Thread 0 Crashed:
0   _______                              0x0000000100255178 _______.PhoneNumberController.viewDidDisappear(Swift.Bool) -> () (PhoneNumberController.swift:97)
1   _______                              0x00000001002551a4 @objc _______.PhoneNumberController.viewDidDisappear(Swift.Bool) -> () (PhoneNumberController.swift:0)
2   UIKit                                0x000000018e7026f4 -[UIViewController _setViewAppearState:isAnimating:] + 524
3   UIKit                                0x000000018e7765b4 -[UIViewController __viewDidDisappear:] + 140
4   UIKit                                0x000000018e7c02e0 -[UINavigationController viewDidDisappear:] + 228
5   UIKit                                0x000000018e7026f4 -[UIViewController _setViewAppearState:isAnimating:] + 524
6   UIKit                                0x000000018e7765b4 -[UIViewController __viewDidDisappear:] + 140
7   CoreFoundation                       0x00000001887ceb10 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 16
8   CoreFoundation                       0x00000001887ce214 _CFXRegistrationPost + 396
9   CoreFoundation                       0x00000001887cdf90 ___CFXNotificationPost_block_invoke + 56
10  CoreFoundation                       0x000000018883db8c -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1500
11  CoreFoundation                       0x000000018870fe64 _CFXNotificationPost + 372
12  Foundation                           0x0000000189244e0c -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
13  UIKit                                0x000000018e9785d8 __102-[UIApplication _handleApplicationDeactivationWithScene:shouldForceExit:transitionContext:completion:]_block_invoke.2100 + 288
14  UIKit                                0x000000018e97bfdc _runAfterCACommitDeferredBlocks + 288
15  UIKit                                0x000000018e96dd50 _cleanUpAfterCAFlushAndRunDeferredBlocks + 556
16  UIKit                                0x000000018e6dd0b4 _afterCACommitHandler + 164
17  CoreFoundation                       0x00000001887e20c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
18  CoreFoundation                       0x00000001887dfcf0 __CFRunLoopDoObservers + 368
19  CoreFoundation                       0x00000001887e0180 __CFRunLoopRun + 1020
20  CoreFoundation                       0x000000018870e2b8 CFRunLoopRunSpecific + 440
21  GraphicsServices                     0x000000018a1c2198 GSEventRunModal + 176
22  UIKit                                0x000000018e7557fc -[UIApplication _run] + 680
23  UIKit                                0x000000018e750534 UIApplicationMain + 204
24  _______                              0x00000001000e3188 main (AppDelegate.swift:25)
25  ???                                  0x00000001876f15b8 0x0 + 0

0 个答案:

没有答案