2015-11-30 32 views
1

我想這樣做,當用戶點擊註銷按鈕,他們必須輸入他們的密碼才能註銷。我如何讓用戶輸入他們的密碼來註銷。解析/ Swift

使用解析和swift。我應該怎麼做呢?

我是否應該從註銷按鈕切換到請求密碼輸入的新視圖控制器?

OR

是有可能有一個彈出式與請求currentUser的密碼的文本框?

+1

我很想知道爲什麼要添加此功能。 – Carl

+1

構建特定於該業務的B2B產品。這樣,沒有人可以登錄應用程序或添加的東西,而不必將他們的密碼放在幾個地方。 –

+0

@Carl將其用作安全措施 –

回答

1

使用UIAlertController通過向警報中添加文本字段來提示用戶輸入密碼(LKAlertController是這方面的一個很好的包裝)。

還有就是你的用戶密碼沒有本地訪問,但你可以嘗試登錄現有的用戶中再次使用PFUser.logInWithUsernameInBackground - 如果這是成功的,叫PFUser.logoutInBackgroundWithBlock()

0

可以顯示UIAlertController與密碼文本字段在它:

let alertController = UIAlertController(...) 
alertController.addTextFieldWithConfigurationHandler { (textField) in 
    textField.placeholder = "Password" 
    textField.secureTextEntry = true 
} 

let logoutAction = UIAlertAction(title: "Logout", style: .Default) { (_) in 
    let textField = alertController.textFields![0] as UITextField 

    logout(textField.text) 
} 

此外,在密碼文本字段配置塊,您可以訂閱UITextFieldTextDidChangeNotification通知,並根據輸入的文本啓用/禁用logoutAction。

相關問題