Lan Yi iOS new control Uidatespickers/uialertcontroller

Source: Internet
Author: User

Today Liu Guobin Teacher spoke two new control Uidatespickers/uialertcontroller, one is a date selector, and the other is a warning window controller.
One, the development uses the date time picker uidatepicker experience. Uidatepicker inheritance with Uicontrol, you can use Uicontrol method -(void) AddTarget: (ID) Target action: (SEL) Action forcontrolevents: ( uicontrolevents) ControlEvents Gets the date time selected. set the display language, 12/24 hours of input, get local time, and limit the selection of time selection; format displays the date and time required for the output to be displayed.

Uidatepicker *tp=[[uidatepicker Alloc]init];

The Uidatepickermodedateandtime enumeration value is 2, and the default property enumeration for general system settings is 0, which is a special

Uidatepickermodedateandtime is the system default, self and set at the time for this

Tp.datepickermode=uidatepickermodedateandtime;

Gets the style (language) that can be tagged//specifies the region in which the selector is located (the language displayed) Chinese "zh_hans_cn" English "en_US"

NSLog (@ "%@", [Nslocale availablelocaleidentifiers]);

Tp.locale=[nslocale localewithlocaleidentifier:@ "BJ_CN"];

Timer ****************

Tp.datepickermode=uidatepickermodecountdowntimer;

Countdown duration, setting the time interval

tp.countdownduration=60*30; Units: seconds/But the minimum screen display is minutes, so multiply by 60, set when the current initial time

tp.minuteinterval=10; Units: Minutes

[Self.view ADDSUBVIEW:TP];

[TP addtarget:self Action: @selector (DoClick) forcontrolevents:uicontroleventvaluechanged];

//      ***********************************

SELF.TP=TP;

}

Events that start when you click on a value change

-(void) doclick{

NSLog (@ "hehe");

}

-(void) moo{

The time of the acquisition is the time of the Observatory, which is to be converted into our own time.

NSLog (@ "%@", self.tp.date);

};

Two

-(void) moo{

In Actionsheet mode, the bottom of the screen is the exclusive line

Uialertaction *okaction=[uialertaction actionwithtitle:@ "OK" style:uialertactionstyledefault Handler:nil];

Uialertaction *cancelaction=[uialertaction actionwithtitle:@ "Cancel" Style:uialertactionstylecancel Handler:nil];

Block

Uialertaction *reaction=[uialertaction actionwithtitle:@ "Restart" Style:uialertactionstyledefault handler:^ ( Uialertaction * _nonnull action) {

^ is a feature of block

[Self rego];

Here you can jump directly to the event method, or you can individually encapsulate the method written on the outside of the call here

NSLog (@ "www");

}];

Create Uialertcontroller

Uialertcontroller *ac=[uialertcontroller alertcontrollerwithtitle:@ "Warning" message:@ "content of Prompt" Preferredstyle: Uialertcontrollerstylealert];

Add button

[AC addaction:okaction];

[AC addaction:cancelaction];

[AC addaction:reaction];

Jump to alert window

[Self Presentviewcontroller:ac animated:yes completion:nil];

Lan Yi iOS new control Uidatespickers/uialertcontroller

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.