一、(正确操作)
_vipOpenView = [[VipOpenAlertView alloc]initWithFrame:self.view.frame title:@""];
_vipOpenView.delegate = self;
_vipOpenView.hidden = YES;
[[UIApplication sharedApplication].keyWindow addSubview:_vipOpenView];
alert = [[UIAlertView alloc]initWithTitle:@"" message:message delegate:self cancelButtonTitle:@"马上升级" otherButtonTitles:title, nil];
[alert show];
二、(错误操作)
alert = [[UIAlertView alloc]initWithTitle:@"" message:message delegate:self cancelButtonTitle:@"马上升级" otherButtonTitles:title, nil];
[alert show];
_vipOpenView = [[VipOpenAlertView alloc]initWithFrame:self.view.frame title:@""];
_vipOpenView.delegate = self;
_vipOpenView.hidden = YES;
[[UIApplication sharedApplication].keyWindow addSubview:_vipOpenView];
使用UIAlertView的show时,系统使用了一个新的Window来展现UIAlertView,所以当show弹窗时,keyWindow已经被替换,dismiss的时候,keyWindow上的视图都会被移除,如果想要_vipOpenView依然存在,必须在UIAlertView show之前添加