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...