import
UIKit
class
ViewController
:
UIViewController
{
var
alertView =
UIAlertView
()
override
func
viewDidLoad() {
super
.viewDidLoad()
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){
println
(
"点击了取消"
)
}
else
{
let
name = alertView.textFieldAtIndex(0)
let
password = alertView.textFieldAtIndex(1)
println
(
"用户名是:\(name!.text) 密码是:\(password!.text)"
)
}
}
override
func
didReceiveMemoryWarning() {
super
.didReceiveMemoryWarning()
}
}
请发表评论