前提:
滿足以下兩個條件(可參考使用該方式)
- 使用 [[[UIApplication sharedApplication] delegate] window] 彈出的View
- 在該View上使用并彈出AlertController
現(xiàn)象:
彈出的AlertController圖層在View圖層下面,遮擋住了AlertController操作
原理:
1.創(chuàng)建一個 ViewController 對象為 tempVc ;
2.將 tempVc.view 添加到需顯示 AlertController 的 View 上 ;
3.用 presentViewController: animated: completion: 顯示 ;
實現(xiàn):
UIAlertController *alvc = [UIAlertController alertControllerWithTitle:@"標(biāo)題" message:nil preferredStyle:(UIAlertControllerStyleAlert)];
UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"重試" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"回調(diào)方法 ----- kkkk");
}];
[alvc addAction:confirmAction];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"掛斷" style:(UIAlertActionStyleDestructive) handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"回調(diào)方法 ----- kkkk");
}];
[alvc addAction:cancelAction];
UIViewController *tempVc = [[UIViewController alloc] init];
[self addSubview:tempVc.view];
[tempVc presentViewController:alvc animated:YES completion:^{
[tempVc.view removeFromSuperview];
}];