【问题标题】:UIAlertController buttons are not visibleUIAlertController 按钮不可见
【发布时间】:2021-02-25 04:23:22
【问题描述】:

我有一个 Objective C 项目并想向用户显示一些警报,在某些 iPad 上 UIAlertController 按钮不可见,我在下面附上了一张图片。 有人遇到过这样的问题吗?有什么解决方法吗?

设备详情 iOS 14.4 iPad 空气 2

使用的示例代码

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@“Alert” message:@“Message” preferredStyle:UIAlertControllerStyleAlert];

        UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@“YES” style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){
            
           
        }];
        UIAlertAction *noAction = [UIAlertAction actionWithTitle:@“NO” style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){
        }];
        [alert addAction:yesAction];
        [alert addAction:noAction];
        [alert show];

图片

【问题讨论】:

  • 请确保您曾经使用任何类别替换颜色或全局使用任何色调颜色来更改按钮,
  • 正是我的问题!我们客户的大约 1500 台 iPad 运行良好,只有一台 iPad mini 显示空按钮。仅当我更改某些辅助功能设置(例如“对比度”)时,我才能重现该问题。但我仍然不知道出了什么问题......

标签: ios objective-c uialertcontroller


【解决方案1】:

这看起来很奇怪。
但我认为问题在于您正在调用show 方法。
你需要'presentViewController',因为它不再是UIAlertView',而是UIAlertViewController

请使用我的 sn-p。

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Alert" message:@"Message" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                        //button click event
                    }];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
[alert addAction:cancel];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];

为了更深入的研究,我推荐这个article

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-15
    • 2021-09-16
    • 1970-01-01
    • 2012-12-09
    • 2016-10-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多