UIAlertController - 在警报中显示空白标题

Posted

技术标签:

【中文标题】UIAlertController - 在警报中显示空白标题【英文标题】:UIAlertController - showing blank titles in the alert 【发布时间】:2016-10-04 14:14:30 【问题描述】:

我们的一个应用程序有警报,我们曾经使用 UIAlertView。自从 UIAlertView 在 ios9 中被弃用以来,我们已经从 UIAlertView 更新到 UIAlertController(从 iOS8 可用)。最近我们收到一位客户的问题,称警报按钮有时显示为空白,但无论标题是否显示,按钮都按预期工作。

设备:iPad mini(第一代) 操作系统版本:iOS9

那么,有时警报按钮显示空白可能是什么问题?

【问题讨论】:

显示设置动作标题的代码。 更改 tintColor。你的 App 必须有一个白色的 tintColor,而不是这些 UIAlertController 捕捉。 显示警报视图控制器按钮操作代码 @OnikIV 对不起,我没听懂你!默认情况下,按钮标题为蓝色。我们无法重现这一点,但我们的客户分享了我们的应用截图,其中包含空白按钮标题。他提到,空白问题并非每次都出现。有时,它们会显示标题,但不是每次都显示。 @SrinivasG 我有这样的行为,而不是 AlertController 更改 tintColor 或一些,在模态显示 PickerViewController 之后,(UIImagePicker ...,CNContactPicker ...,DocumentPicker ... 等等)。如果您有多个故事板,我不知道,但听起来好像在某些地方您正在更改 App tinColor。查看您所有的代码“tintColor 属性以检查以及 Story 和 Xibs。祝你好运。 【参考方案1】:

我试了样例一,效果很好

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Show Actions" message:@"Action Title" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *save = [UIAlertAction actionWithTitle:@"SAVE" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:save];

UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"CANCEL" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:cancel];

UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:ok];

[alertController addAction:ok];
[alertController addAction:save];
[alertController addAction:cancel];

[self presentViewController:alertController animated:YES completion:nil];

输出结果是

【讨论】:

客户报告按钮标题显示了一些时间,但不是每次都显示。有时,它们是空白的 你试过我的回答了吗? 我已经使用了类似的代码,但文字不同;)顺便说一句,问题不是每次都重现。所以,确认修复也很困难:(

以上是关于UIAlertController - 在警报中显示空白标题的主要内容,如果未能解决你的问题,请参考以下文章

从第一个 UIAlertController 打开第二个 UIAlertController

如果已经显示警报,则显示 UIAlertController

UIAlertController - 如果警报第一次解除,则不执行操作

为啥这个 UIAlertController 不显示?

iOS:UIAlertController 上的 textField 成为当前警报时的第一响应者

警报中的指示器,指示器不显示(使用 UIAlertController 解决)