Ios7_ how to implement Uialertview and monitor click events

Source: Internet
Author: User

1. m file in Viewcontroller, comply with <UIAlertViewDelegate> Agent agreement

@interface moboviewcontroller () <UIAlertViewDelegate>

2. Implement Uialertview in-(void) Viewdidload method

1- (void) Viewdidload2 {3 [Super Viewdidload];4     5   //1. Initialize Alertview6Uialertview *altview = [[Uialertview alloc]initwithtitle:[self Alttitle] message:[self AltMSG]Delegate: Self cancelbuttontitle:[self cancelbtntitle] otherbuttontitles:[self Otherbtntitle], nil];7     //2. Display Alertview8 [Altview show];9     Ten}

3, continue to implement other methods, return to the various headings and monitoring button click event Agent method

1 //return title2-(NSString *) alttitle{3     return @"Offline Notification";4 }5 6 //returns the body of the message7-(NSString *) altmsg{8     return @"your account is logged off-site, the password may be leaked, it is recommended to go to http://mobodemy.com to modify. ";9 }Ten  One //Returns the Exit button caption A-(NSString *) Cancelbtntitle { -     return @"Exit"; - } the  - //return Login button title --(NSString *) Otherbtntitle { -     return @"Re-login"; + } -  + //Monitor Click-Time Proxy Method A- (void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (nsinteger) Buttonindex at { -NSString *btntitle =[Alertview Buttontitleatindex:buttonindex]; -     if([Btntitle isequaltostring:[self Cancelbtntitle]]) { -NSLog (@"you clicked the exit"); -     } -     Else if([Btntitle isequaltostring:[self Otherbtntitle]]) { inNSLog (@"you clicked the Re-login button"); -     } to}

Ios7_ how to implement Uialertview and monitor click events

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.