标签:
@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
-(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"]) {
//本地有手势密码
[[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"]) {
//本地有手势密码
[[NSNotificationCenter defaultCenter]addObserver:selfselector:@selector(willInterForeground) name:UIApplicationWillResignActiveNotification object:nil];
}
}
return self;
}
-(void)willInterForeground
{
if (self) {
[self dismissWithClickedButtonIndex:0 animated:NO];
}
}
-(void)dealloc{
NSLog(@"移除观察者");
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
HZSAlertView *alertview = [[HZSAlertView alloc]initWithTitle:nilmessage:@"修改成功" delegate:nil cancelButtonTitle:@"确定"otherButtonTitles:nil];
[alertview show];HZSAlertView *alertview = [[HZSAlertView alloc]initWithTitle:nilmessage:@"请选择手机号的运营商" delegate:self cancelButtonTitle:@"取消"otherTitles:@[@"联通",@"电信",@"移动"]];
alertview.tag=444444;
[alertview show];iOS7之后全局移除UIAlertView(app退到后台)
标签:
原文地址:http://www.cnblogs.com/huangzs/p/4472199.html