所以我在一个项目中陷入困境,我们在整个项目的多个地方不断遇到这个问题。当我们以标准、典型的方式显示 UIAlertView 时,标题不会显示在警报上,只会显示描述和按钮。我们像任何人一样进行初始化和显示:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Are you sure?" message:@"Deleting a ..." delegate:self cancelButtonTitle:@"Delete" otherButtonTitles:@"Cancel", nil];
[alert show];
有没有人遇到过这个问题?我们没有导入和依赖性来改变任何东西,也没有做任何我们可以判断会导致这种情况的事情。
编辑:这是我所看到的示例:
最佳答案
我也遇到了同样的问题。根本原因是我在项目中使用了“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/