您的位置:首页 > 产品设计 > UI/UE

IOS UIAlertView

2015-11-15 17:56 387 查看
//
//  ViewController.swift
//  UIAlertView
//
//  Created by liaojianguo on 15/11/15.
//  Copyright © 2015年 liaojianguo. All rights reserved.
//

import UIKit

class 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.
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: