IOS UIAlertView

来源:互联网 发布:诛仙手游数据互通吗 编辑:程序博客网 时间:2024/06/10 13:23



////  ViewController.swift//  UIAlertView////  Created by liaojianguo on 15/11/15.//  Copyright © 2015年 liaojianguo. All rights reserved.//import UIKitclass ViewController: UIViewController {        func alertView(alertView : UIAlertView,clickedButtonAtIndex buttonIndex:Int)    {        if(buttonIndex==alertView.cancelButtonIndex)        {            print("点击了取消")        }else        {            let name = alertView.textFieldAtIndex(0)            let password = alertView.textFieldAtIndex(1)            print("用户名是:\(name!.text) 密码是:\(password!.text)")        }    }    override func viewDidLoad() {        super.viewDidLoad()        // Do any additional setup after loading the view, typically from a nib.        let alertView = UIAlertView()        alertView.message="你确认删除这篇文章吗?"        alertView.title="系统提示"        alertView.addButtonWithTitle("取消")        alertView.addButtonWithTitle("确认")        alertView.cancelButtonIndex=0        alertView.delegate=self//对应UIAlertViewDelegate看一看其所有的方法                           //告警框有下面4种样式        //Default:默认样式        //PlainTextInput:带输入框的告警框        //SecureTextInput:带密码框的告警框        //LoginAndPasswordInput:带输入框和密码框的告警框        alertView.alertViewStyle = UIAlertViewStyle.LoginAndPasswordInput        //alertView.alertViewStyle = UIAlertViewStyle.PlainTextInput                                alertView.show()            }    override func didReceiveMemoryWarning() {        super.didReceiveMemoryWarning()        // Dispose of any resources that can be recreated.    }}


0 0
原创粉丝点击