OGeek|极客世界-中国程序员成长平台

标题: ios - UIAlertController 被窗口上的 View 覆盖 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 23:55
标题: ios - UIAlertController 被窗口上的 View 覆盖

当我将 UIView 添加到 keyWindow 时,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

你知道怎么解决吗?



Best Answer-推荐答案


将 View 添加到 window 将覆盖任何未添加到 window 并放置在其顶部的 View 。窗口层是您可以添加内容的最上层。如果您希望将 UIView 放在 UIAlertViewController 下方,则必须将该 UIView 添加到 UIViewController 的 subview 中的 .view,您在其中呈现 UIAlertController

关于ios - UIAlertController 被窗口上的 View 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42406834/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4