IOS: uialertview automatically disappears

Source: Internet
Author: User

Tyle = "margin-top: 20px; margin-Right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', console, verdana,; Font: normal 14px/26px Arial ">

Before writingProgramA lot of prompt information is used in the process, so it is very natural to useUialertviewControl. However, the prompt information sometimes only needs to be prompted and does not need to be operated. In this case, the prompt box will disappear automatically.OK.UialertviewAfter2 SThere are two ways to make it disappear automatically:(1)IntegrationNstimer

Define uialertview * basealert;

-(Void) implements mdismiss: (nstimer *) timer {

[Basealert dismisswithclickedbuttonindex: 0 animated: No]; // important

[Basealert release];

Basealert = NULL;

}

-(Void) presentsheet {

Basealert = [[uialertview alloc] initwithtitle: @ "alert" message: @ "\ nmessage message" delegate: Self cancelbuttontitle: Nil otherbuttontitles: Nil];

[Nstimer scheduledtimerwithtimeinterval: 2.0f target: Self selector: @ selector (required mdismiss :) userinfo: Nil repeats: No];

[Basealert show];}

(2)UsePerformselector: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: nilotherbuttontitles: Nil];

[Alert show];

[Self defined mselector: @ selector (dimissalert :) withobject: Alert afterdelay: 2.0];

}

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.