Swift Learning--Uialertviewcontroller-alert

Source: Internet
Author: User

//
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.