横向模式下的UIAlertView不显示消息

Rog*_*Rog 1 uialertview

可能重复:
UIAlertView未显示消息文本

我试图在横向模式下为应用程序创建一个简单的UIAlertView,但我看到的只是标题和按钮,但没有实际的消息.

它与UIAlertView在屏幕上可用的空间有关,好像我删除了几个按钮然后消息显示正常.

有没有办法强制UIAlertView调整大小以适应?

相关代码在这里

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Free Update",nil) 
                                                message:NSLocalizedString(@"There is a new version of this app available in the App Store. Download it now.",nil) 
                                               delegate:self 
                                      cancelButtonTitle:NSLocalizedString(@"Don't remind me",nil)
                                      otherButtonTitles:NSLocalizedString(@"Download",nil), NSLocalizedString(@"Remind me later", nil), nil];
[alert show];
[alert release];
Run Code Online (Sandbox Code Playgroud)

这就是结果:

在此输入图像描述

Cha*_*aka 8

有点脏,但它的工作原理:o)只需将UILabel添加到UIAlertView

UILabel *messageLabel = [[UILabel alloc] initWithFrame:CGRectMake( alert.frame.origin.x + 10, 16, 260, 70)];
messageLabel.backgroundColor = [UIColor clearColor];
messageLabel.text = @"Your message";
messageLabel.textColor = [UIColor whiteColor];
messageLabel.lineBreakMode = UILineBreakModeWordWrap;
messageLabel.numberOfLines = 2;
messageLabel.font = [UIFont systemFontOfSize:12];
messageLabel.textAlignment = UITextAlignmentCenter;
[alert addSubview:messageLabel];
Run Code Online (Sandbox Code Playgroud)

另一个肮脏的黑客,以获得标题和按钮之间的更多空间.

- (void)willPresentAlertView:(UIAlertView *)alertView {
    float moreSpace = 20.0f;

    alertView.frame = CGRectMake(alertView.frame.origin.x, alertView.frame.origin.y - moreSpace
                             ,alertView.frame.size.width, alertView.frame.size.height + moreSpace*2 + 10.0f);

    for ( UIView *view in [alertView subviews] ) {
        if ( (view.class != UILabel.class ) && ( view.class != UIImageView.class ) ) {
            [view setTransform:CGAffineTransformMakeTranslation(0, moreSpace * 2)];
        }
    }
}
Run Code Online (Sandbox Code Playgroud)