Create a new view Controller HZSAlertView.h integrated Uialertview
@interface Hzsalertview:uialertview
-(Instancetype) Initwithtitle: (NSString *) title message: (NSString *) message delegate: (ID) Delegate Cancelbuttontitle :(NSString *) cancelbuttontitle otherbuttontitles: (NSString *) otherbuttontitles, ...;
-(Instancetype) Initwithtitle: (NSString *) title message: (NSString *) message delegate: (ID) Delegate Cancelbuttontitle :(NSString *) cancelbuttontitle othertitles: (Nsarray *) otherbuttontitles;
@end
The following methods can be implemented in HZSALERTVIEW.M
-(Instancetype) Initwithtitle: (NSString *) title message: (NSString *) message delegate: (ID) Delegate Cancelbuttontitle :(NSString *) cancelbuttontitle othertitles: (Nsarray *) otherbuttontitles
{
if (self = [super Initwithtitle:title message:message delegate:delegate cancelbuttontitle:cancelbuttontitle Otherbuttontitles:[otherbuttontitles Firstobject], nil]) {
for (int i=1; i<[otherbuttontitles count]; i++) {
[Self addbuttonwithtitle:[otherbuttontitles objectatindex:i]];
}
if ([[nsuserdefaultsstandarduserdefaults]objectforkey:@ "Gesturecode"]) {
Local gesture Password
[[Nsnotificationcenter Defaultcenter]addobserver:selfselector: @selector (willinterforeground) Name: Uiapplicationwillresignactivenotification Object:nil];
}
}
return self;
}
-(Instancetype) Initwithtitle: (NSString *) title message: (NSString *) message delegate: (ID) Delegate Cancelbuttontitle :(NSString *) cancelbuttontitle otherbuttontitles: (NSString *) Otherbuttontitles, ...
{
if (self = [super Initwithtitle:title message:message delegate:delegate cancelbuttontitle:cancelbuttontitle Otherbuttontitles:otherbuttontitles, nil]) {
if ([[nsuserdefaultsstandarduserdefaults]objectforkey:@ "Gesturecode"]) {
Local gesture Password
[[Nsnotificationcenter Defaultcenter]addobserver:selfselector: @selector (willinterforeground) Name: Uiapplicationwillresignactivenotification Object:nil];
}
}
return self;
}
-(void) Willinterforeground
{
if (self) {
[Self dismisswithclickedbuttonindex:0 animated:no];
}
}
-(void) dealloc{
NSLog (@ "Remove observer");
[[Nsnotificationcenter Defaultcenter] removeobserver:self];
}
Call the time
Hzsalertview *alertview = [[Hzsalertview alloc]initwithtitle:nilmessage:@ "modified successfully" Delegate:nil cancelButtonTitle:@ "OK" Otherbuttontitles:nil];
[Alertview show];
Hzsalertview *alertview = [[Hzsalertview alloc]initwithtitle:nilmessage:@ "Please select the operator of the mobile number" delegate:self cancelbuttontitle:@ "Cancel" othertitles:@[@ "Unicom", @ "Telecom", @ "mobile"];
alertview.tag=444444;
[Alertview show];
IOS7 Global removal after Uialertview (app fallback to background)