UIAlertView不显示消息文本 [英] UIAlertView not showing message text

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

问题描述

我正在创建一个在纵向布局中工作正常的UIAlertView,但在横向模式下 - 消息不会出现。

I am bringing up an UIAlertView that works fine in portrait layout, but when in landscape mode - the message doesn't appear.

这是一个标准的UIAlertView,有三个按钮。

It is a standard UIAlertView, with three buttons.

UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"one", @"two", nil];

我试过按下按钮(根据消息标签的高度)并调整警报的大小根据重新定位的按钮,但仍然没有显示消息,尽管有足够的显示空间。

将UILabel背景设置为某种颜色以进行调试显示它只是没有显示..

I have tried moving the buttons down (according to the height of the message label) and resizing the alert according to the relocated buttons, but the message still doesn't appear, despite there being plenty of room for display.
Setting the UILabel background to some color for debugging shows that it just isn't displayed..

编辑:

UILabel 在那里 - 它只是没有显示。

willPresentAlertView 方法中,我可以在NSAlertView的子视图中看到UILabel。

The UILabel is there - It's just not being displayed.
In the willPresentAlertView method, I can see the UILabel in the NSAlertView's subviews.

推荐答案

它似乎是UIAlertView的布局代码的错误。在调试器中摆弄了一下后,我设法解决了这个问题:

It appears to be a bug with the layout code for UIAlertView. After fiddling a bit in the debugger I managed to get this workaround:

UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"one", @"two", nil];

[alert show];

// for some reason we have alpha 0 for 3 or 4 buttons
[[[alert subviews] objectAtIndex:2] setAlpha:1];
// also, for 3 buttons the height goes to 10 -> proof of concept 'fix'
[[[alert subviews] objectAtIndex:2] setFrame:CGRectMake(12, 45, 260, 24)];

[alert release];

这只是一个概念验证。一个真正的工作应该迭代子视图并仅修复高度为小或alpha == 0

This is just a proof of concept. A real workaroung should iterate ober the subviews and fix only labels that have either height to small or alpha==0

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

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