2015-06-25 26 views
1

我正在使用解析登錄控制器(默認解析一個他們提供)來實現我的應用程序的用戶登錄/通行證。它工作正常,我可以登錄,註冊和整個事情。唯一的問題是,如果密碼錯誤,我想添加一個警報,現在只有在密碼錯誤時纔會打印println(「無法登錄...」),並且用戶不知道他們的密碼是錯誤的。我添加了一個提醒,但有些原因沒有出現。我得到的錯誤信息是「警告:嘗試呈現其視圖不在窗口層次結構中!」AlertViewController在解析

這裏是我加入到我的代碼警報:

func logInViewController(logInController: PFLogInViewController!, didFailToLogInWithError error: NSError!) { 
    println("Failed to login...") 
    let alertView = UIAlertController(title: "Failed to login...", message: "Incorrect password or username.", preferredStyle: .Alert) 
    alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil)) 
    presentViewController(alertView, animated: true, completion: nil) 

} 

我想可能是因爲我使用他們提供的解析默認的登錄屏幕是不是我的故事板,但是從剖析框架調用(?)。我如何去添加一個警報視圖?

謝謝!

喬希

回答

1

試試這個

logInController.presentViewController(alertView, animated: true, completion: nil) 

我想解析顯示一個警告,當你使用無效憑據登錄,因此這可能表明第二 - 有警報駁回後。

+0

謝謝!精彩地工作。 –

+1

你有2個提醒嗎?或者只是你的預期? – DogCoffee

+0

只有我想象的那樣。 –