Ios:uialertview automatically disappears

Source: Internet
Author: User

A lot of information is used in the process of writing a program, so it is very natural to use the Uialertview control. However, the information of these hints is sometimes just a hint on the line, do not have to operate, then this prompt box will automatically disappear on the OK . uialertview eject after 2s Let it disappear automatically, two ways: (1) combine nstimer

Define Uialertview *basealert;

-(void) Performdismiss: (Nstimer *) Timer {

[Basealert dismisswithclickedbuttonindex:0 Animated:no];//important

[Basealert release];

Basealert = NULL;

}

-(void) Presentsheet {

Basealert = [[Uialertview alloc] initwithtitle:@ "Alert" message:@ "\nmessage message message" Delegate:self CancelButton Title:nil Otherbuttontitles:nil];

[Nstimer scheduledtimerwithtimeinterval:2.0f target:self selector: @selector (performdismiss:) Userinfo:nil repeats: NO];

[Basealert show]; }

(2) Use Performselector: withobject:afterdelay: Method

-(void) Dimissalert: (Uialertview *) Alert {

if (alert) {

[Alert Dismisswithclickedbuttonindex:[alert Cancelbuttonindex] animated:yes];

[Alert release];

 }

}

-(void) showalert{

Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "title" message:@ "message" Delegate:nil Cancelbuttontitle:nil Otherbuttontitles:nil];

[alert show];

[Self performselector: @selector (dimissalert:) Withobject:alert afterdelay:2.0];

}

Ios:uialertview automatically disappears

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.