Ios7 _ How to Implement UIAlertView and listen to click events, ios7uialertview

Source: Internet
Author: User

Ios7 _ How to Implement UIAlertView and listen to click events, ios7uialertview

1. In the viewController. m file, follow the <UIAlertViewDelegate> proxy Protocol

@ Interface moboViewController () <UIAlertViewDelegate>

2. Implement UIAlertView in the-(void) viewDidLoad Method

1-(void) viewDidLoad 2 {3 [super viewDidLoad]; 4 5 // 1. initialize alertView 6 UIAlertView * altView = [[UIAlertView alloc] initWithTitle: [self altTitle] message: [self altMSG] delegate: self cancelButtonTitle: [self cancelBtnTitle] otherButtonTitles: [self otherBtnTitle], nil]; 7 // 2. alertView 8 [altView show]; 9 10}

 

3. Continue to implement other methods, return various titles, and listen to the button to click the event proxy method

1 // return Title 2-(NSString *) altTitle {3 return @ "deprecate notification"; 4} 5 6 // return message body 7-(NSString *) altMSG {8 return @ "your account is logged on remotely, the password may be leaked, it is recommended to go to The http://mobodemy.com to modify. "; 9} 10 11 // the title of the return exit Button 12-(NSString *) cancelBtnTitle {13 return @" quit "; 14} 15 16 // return to the logon button Title 17-(NSString *) otherBtnTitle {18 return @ "Log on again "; 19} 20 21 // Method 22-(void) alertView (UIAlertView *) alertView clickedButtonAtIndex :( NSInteger) buttonIndex23 {24 NSString * btnTitle = [alertView Duration: buttonIndex]; 25 if ([btnTitle isEqualToString: [self cancelBtnTitle]) {26 NSLog (@ "you clicked to exit"); 27} 28 else if ([btnTitle isEqualToString: [self otherBtnTitle]) {29 NSLog (@ "you clicked"); 30} 31}

 


For ios-developed UIAlertView, I want to click the OK button and push it to another ShowViewController. How can I do this? Some code:

Add a line of code before [alert show ];
Alert. delegate = self;

In addition, your memory management is faulty,
If your self. alert describes retain, your alert needs to be release once;
After show, release

How does ios7 customize UIAlertView?

This official version should have the UIAlertView tool corresponding to ios7. This function should not be canceled...
 

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.