簡體   English   中英

PFUser.loginWithUserInBackground可在模擬器上使用,但不適用於ios設備

[英]PFUser.loginWithUserInBackground works on simulator but not on ios device

我具有以下登錄功能,該功能在模擬器上可以登錄並運行回調,但在ipad mini iOS 8.1.2上不運行回調。 在我的iPad上,activityIndi​​cator一直保持旋轉狀態直到永恆。

我連接了iPhone 4,iOS 8.1.2,並且似乎已經在其中登錄。 這表明登錄功能大約在3到4周前就已經開始工作,當時我對此進行了測試。

這里有什么問題?

@IBAction func login(sender: AnyObject) {

    var errorMessage = self.validateForm()
    if !errorMessage.isEmpty {
        var alert = UIAlertView(title: "", message: errorMessage, delegate: nil, cancelButtonTitle: "OK")
        alert.show()
        return
    }

    self.activityIndicator.hidden=false
    self.activityIndicator.startAnimating()

    NSLog("Logging in ...")
    PFUser.logInWithUsernameInBackground(emailAddressTextField.text, password: passwordTextField.text){
        (user:PFUser!, error:NSError!) -> Void in

        self.activityIndicator.stopAnimating()
        self.activityIndicator.hidden=true

        if error == nil {
            if (user != nil){
            NSLog("login successful with: \(user)")
            self.dismissViewControllerAnimated(false, completion: nil)
            }
        } else if error != nil {

            NSLog("login failed")
            var messageForUser = "Please try again"
            if error.code == 101 {
                messageForUser = "Please check your email address and password"
            } else if error.code == 100 {
                messageForUser = "Please check your internet connection"
            }

            var alert = UIAlertView(title: "Problem logging in", message: messageForUser, delegate: nil, cancelButtonTitle: "OK")
            alert.show()
        }
    }
}

該應用程序是一個標簽欄應用程序。 我按下一個按鈕,將我帶到單獨的loginviewcontroller。 當tabbarcontroller首次加載時,這是堆棧跟蹤:

2015-01-21 16:07:22.059 Tya[1610:323782] Warning: A long-running operation is being executed on the main thread. 
 Break on warnBlockingOperationOnMainThread() to debug.
2015-01-21 16:07:22.465 Tya[1610:323782] NewDeliveryVC loaded
2015-01-21 16:07:22.468 Tya[1610:323782] Warning: A long-running operation is being executed on the main thread. 
 Break on warnBlockingOperationOnMainThread() to debug.
2015-01-21 16:07:22.536 Tya[1610:323782] - Current user is nil.
2015-01-21 16:07:22.537 Tya[1610:323782] - currentInput: 0
2015-01-21 16:07:22.600 Tya[1610:323782] Not logged-in

然后,當我到達loginviewcontroller時:

2015-01-21 16:13:19.564 Tya[1610:323782] login Button tapped
2015-01-21 16:13:19.639 Tya[1610:323782] viewDidLoad: LoginVC.
2015-01-21 16:13:19.681 Tya[1610:323782] viewWillAppear: LoginVC

因此,堆棧跟蹤說要在warnBlockingOperationOnMainThread上放置一個符號斷點。

我這樣做是按照這個問題的解釋: 在主線程上正在執行長時間運行的Parse操作

單擊結果顯示本地數據存儲的appDelegate中存在問題。

我將“ Parse.enableLocalDatastore”注釋掉了。 禁用本地數據存儲后,我現在可以登錄。

(本地數據存儲也使我無法固定應用程序的另一部分,因此我已正式使用它。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM