import UIKit
class ViewController: UIViewController ,UITextFieldDelegate,UITextViewDelegate,UIActionSheet Delegate,UIAlertViewDelegate{
override func viewDidLoad() {
super.viewDidLoad()
let alertView = UIAlertView()
alertView.title = "系統(tǒng)提示"
alertView.message = "您做好準(zhǔn)備了嗎?"
alertView.addButtonWithTitle("取消")
alertView.addButtonWithTitle("確定")
alertView.cancelButtonIndex = 0
alertView.delegate = self
alertView.alertViewStyle = UIAlertViewStyle.LoginAndPasswordInput
alertView.show()
}
func alertView(alertView:UIAlertView, clickedButtonAtIndex buttonIndex:Int){
if(buttonIndex == alertView.cancelButtonIndex){
print("點(diǎn)擊取消")
}else{
print("點(diǎn)擊確定")
let name = alertView.textFieldAtIndex(0)
let password = alertView.textFieldAtIndex(1)
print("用戶名是: \(name!.text) 密碼是:\(password!.text)")
}
}
}
Swift告警框(UIAlertView)的用法
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
推薦閱讀更多精彩內(nèi)容
- 1,下面代碼創(chuàng)建并彈出一個(gè)告警框,并帶有“取消”“確定”兩個(gè)按鈕(注:自IOS8起,建議使用UIAlertCont...
- import UIKit override func viewDidLoad() {super.viewDidLo...