从后台返回时应用程序崩溃

时间:2017-07-25 00:05:28

标签: ios swift

我的应用在用户的第一个lgin中创建了一个大型数据库。我花了大约2分钟来创建这家银行。当我正处于这个过程的中间并且我回到应用程序并且在我再次触摸应用程序之后它会显示最后一个屏幕的一部分然后中断。这个问题似乎很容易解决,但是我无法调试,因为它只发生在设备上,只有在没有调试时才会发生。当我调试应用程序时,它只是继续它停止的过程。可能有什么不对?如果它有帮助,我会附上我的AppDelegate。

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        FirebaseApp.configure()
        FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
        GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
        GIDSignIn.sharedInstance().delegate = self
        Fabric.with([Crashlytics.self])

        let applicationFrame = UIScreen.main.bounds
        let window = UIWindow(frame: applicationFrame)
        window.makeKeyAndVisible()
        self.window = window
        UIApplication.shared.statusBarStyle = .lightContent

        IQKeyboardManager.sharedManager().enable = true

        let tutorialIntroduced = self.defaults.bool(forKey: "tutorialIntroduced")

        if !tutorialIntroduced {
            presentTutorial()

        } else {
            if (Auth.auth().currentUser) != nil {

                if self.defaults.object(forKey: "completeDB") == nil {
                    let vc = UIStoryboard.init(name: "SignIn", bundle: Bundle.main).instantiateViewController(withIdentifier: "DBCreatingViewController") as! DBCreatingViewController
                    self.window?.rootViewController = vc

                } else {
                    if self.defaults.bool(forKey: "completeDB") == true {
                        presentHome()
                    } else {
                        let vc = UIStoryboard.init(name: "SignIn", bundle: Bundle.main).instantiateViewController(withIdentifier: "DBCreatingViewController") as! DBCreatingViewController
                        self.window?.rootViewController = vc
                    }
                }

            } else {
                presentSignIn()
            }
        }

        self.locationManager.requestAlwaysAuthorization()
        self.locationManager.delegate = self
        self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
        self.locationManager.startUpdatingLocation()

        let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
        application.registerUserNotificationSettings(settings)
        application.registerForRemoteNotifications()

        return true
    }

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        print("Message ID \(userInfo["gcm.message_id"]!)")
        print(userInfo)
    }

    func applicationWillResignActive(_ application: UIApplication) {

    }

    func applicationDidEnterBackground(_ application: UIApplication) {

    }

    func applicationWillEnterForeground(_ application: UIApplication) {

    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        FBSDKAppEvents.activateApp()
    }

    func applicationWillTerminate(_ application: UIApplication) {
    }

0 个答案:

没有答案