//
Viewcontroller.swift
Alertview
//
Created by Su on 15/12/7.
Copyright©2015 year Tian. All rights reserved.
//
Import UIKit
Class Viewcontroller:uiviewcontroller {
var controller:uialertcontroller!
Override Func Viewdidload () {
1. Forcing the optional value to be split (unwrap)
2. Declaring implicitly unwrapped optionals value, typically used for properties in a class
Super.viewdidload ()
Creating an Uialertcontroller instance
Controller = Uialertcontroller (title: "I am * * *", message: "Love my Click OK", PreferredStyle:UIAlertControllerStyle.Alert)
Controller.addtextfieldwithconfigurationhandler {(textfiled:uitextfield!), Void in
Textfiled.placeholder = "We all Love Swift"
}
Create action
Let action = uialertaction (title: "OK", Style:UIAlertActionStyle.Default) {(paramaction:uialertaction! ), Void in
Print ("True love!")
// }
Let action = uialertaction (title: "OK", Style:UIAlertActionStyle.Default) {(paramactoin:uialertaction!), Void in
If let Textfields = self.controller.textFields {
Let Txtfields = Textfields as [Uitextfield]
Let txt = txtfields[0].text
Print ("Input content is: \ (TXT)")
}
}
Let Alertcontroller add action
Controller.addaction (Action)
}
Override func Viewdidappear (Animated:bool) {
Super.viewdidappear (animated)
Self.presentviewcontroller (Controller, animated:true, Completion:nil)
}
Override Func didreceivememorywarning () {
Super.didreceivememorywarning ()
Dispose of any resources the can be recreated.
}
}
Swift Learning--Uialertviewcontroller-alert