当我向 keyWindow 添加 UIView 时,alertController 被 View 覆盖。这是代码。
- (void)touch {
UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow;
UIView *viewhaha = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
viewhaha.backgroundColor = [UIColor redColor];
[currentWindow addSubview:viewhaha];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"123" message:@"123" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"123" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
[alertController addAction:action1];
[self presentViewController:alertController animated:YES completion:^{
}];
}
这是图像。 Image
你知道如何解决吗?
最佳答案
向窗口
添加 View 将覆盖任何未添加到窗口
并放置在其顶部的 View 。窗口层是您可以添加内容的最上层。如果您希望将 UIView
放置在 UIAlertViewController
下方,则必须将该 UIView
添加到 UIViewController
的 subview 中的 .view
,您在其中呈现 UIAlertController
。
关于ios - UIAlertController 被窗口上的 View 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42406834/