Swift告警框(UIAlertView)的用法

import UIKit

class ViewController: UIViewController        ,UITextFieldDelegate,UITextViewDelegate,UIActionSheet  Delegate,UIAlertViewDelegate{
override func viewDidLoad() {
    super.viewDidLoad()


 let alertView = UIAlertView()
    alertView.title = "系统提示"
    alertView.message = "您做好准备了吗?"
    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("点击取消")
    }else{
        print("点击确定")
        let name = alertView.textFieldAtIndex(0)
        let password = alertView.textFieldAtIndex(1)
        
        print("用户名是: \(name!.text) 密码是:\(password!.text)")

    }
}

}

你可能感兴趣的:(Swift告警框(UIAlertView)的用法)