ios - iOS 7 上的 UIAlertView 不显示标题

标签 ios ios7 uialertview

所以我在一个项目中陷入困境,我们在整个项目的多个地方不断遇到这个问题。当我们以标准、典型的方式显示 UIAlertView 时,标题不会显示在警报上,只会显示描述和按钮。我们像任何人一样进行初始化和显示:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Are you sure?" message:@"Deleting a ..." delegate:self cancelButtonTitle:@"Delete" otherButtonTitles:@"Cancel", nil];
[alert show];

有没有人遇到过这个问题?我们没有导入和依赖性来改变任何东西,也没有做任何我们可以判断会导致这种情况的事情。

编辑:这是我所看到的示例: enter image description here

最佳答案

我也遇到了同样的问题。根本原因是我在项目中使用了“UIFont+Replacement”。在 iOS 7 中,系统将使用“UIFont fontWithDescriptor:”为系统控件中的标签设置字体。

我添加了一个判断,判断字体替换是否用于像UIAlertView这样的系统控件。请检查我的代码,到目前为止它运行良好:

UIFontDescriptor *replaceDescriptor = descriptor;
if (![descriptor.fontAttributes objectForKey@"NSCTFontUIUsageAttribute"] 
|| ![((NSString *)[descriptor.fontAttributes objectForKey:@"NSCTFontUIUsageAttribute"])     
isEqualToString:@"UICTFontUsageEmphasizeBody"]) 
{
NSString *replacementFontName = [replacementDictionary objectForKey:descriptor.postscriptName];
replaceDescriptor = [UIFontDescriptor fontDescriptorWithName:replacementFontName size:pointSize];
}
return [self replacement_fontWithDescriptor:replaceDescriptor size:pointSize];

关于ios - iOS 7 上的 UIAlertView 不显示标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19845755/

相关文章:

objective-c - UIAlertView 在 iPhone 上不显示

iphone - RestKit:如何为不同的键名进行映射

ios - UITextField 上的下拉菜单?

ios - 如何在 ios 中禁用警报 View 的索引

iphone - 如何使用 QBRTCSession 对象发送自定义字符串

iphone - 用于识别所选路径的按钮

ios - 检测互联网连接并显示 UIAlertview Swift 3

ios - UIPasteboard图像无法插入Notes.app ios8

objective-c - UILabel 调整高度不起作用

ios - 什么是iOS 7中UDID或UUID的副本