给页面添加了蒙版,将蒙版view放在了window上
self.window = [UIApplication sharedApplication].keyWindow;
[self.window addSubview:self.view];
但是有要求点击蒙版上的一个按钮,需要弹出提示框。
如果写UIAlertController的话,弹出的提示框在蒙版下层,会被挡住。
// UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请输入邀请码" preferredStyle:UIAlertControllerStyleAlert];
// UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
// }];
// [alert addAction:cancelAction];
// UIViewController * rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
// [rootViewController presentViewController:alert animated:YES completion:^{
// }];
然后查了一下发现:IOS8中,Apple将UIActionSheet和UIAlertView整合成一个接口UIAlertController。
原来的是一个view,展示在window视图之上。现在改成了controller,展示方式变成由当前的controller直接present出来。
所以,就用老方法,UIAlertView,是显示在window之上的,所以这样就把蒙版挡住提示框的问题解决了。
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示"
message:@"请输入邀请码"
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil, nil];
[alert show];