iOS 8:UIAlertView / UIAlertController不显示文本或按钮 [英] iOS 8: UIAlertView / UIAlertController not showing text or buttons

查看:289
本文介绍了iOS 8:UIAlertView / UIAlertController不显示文本或按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIAlertView,它在iOS 7中得到了很好的展示,但在iOS 8中,它没有显示任何按钮或标签。警报仍然可见,但只是一个小白框。
确定和取消按钮也会显示他们的事件,但是没有文本可见。

I have an UIAlertView which is getting shown perfectly in iOS 7 but in iOS 8, it does not show any buttons or labels. Alert is still visible but just a small white box. The OK and cancel buttons take their events as well but no texts are visible.

我已经使用此警报显示点击按钮

I have used this alert to show on click of a button

- (IBAction)sel_btnLogout:(id)sender {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Logout!" message:@"Are you sure you want to logout?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
    [alert show];
}

我检查了iOS 8中的帧:它给出了(0,0, 0,0)但是在iOS 7中它给出了一个确定的值。

I checked the frame in iOS 8: it is giving (0,0,0,0) but in iOS 7 it is giving a definite value.

我还检查了迭代到uialertview的子视图。在iOS7中,它进入循环,因为它找到警报的子视图。在iOS8中,它表示没有alertView的子视图。

I also checked for iterating into the subviews of uialertview. In iOS7, it goes in the loop, as it finds alert's subviews. In iOS8, it says there are no subviews of alertView.

推荐答案

我得到了我的问题的答案。问题是我在我的项目中使用了UIFont + Replacement类别。这在iOS 7上运行良好,但在iOS 8上它使用了一些不推荐使用的方法。因此,我不知道为什么,但只有我的提醒视图没有显示任何标签。

I got the answer to my issue. The issue was that I was using UIFont+Replacement category in my project. This was working fine on iOS 7 but on iOS 8 it was using few deprecated methods. Due to this, I don't know why, but only my alert view was not showing any labels.

解决方案:从项目中删除类别并设置字体通过xib。一旦我们将任何字体的.tff文件放在项目工作区中,我们就会在自定义字体下的xib中看到这些字体名称。无需使用UIFont +替换类别。

这篇关于iOS 8:UIAlertView / UIAlertController不显示文本或按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆