UIAlertView not showing message text

前端 未结 3 652
情歌与酒
情歌与酒 2021-01-17 05:26

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

It is a standard UIAlertView, with thre

3条回答
  •  佛祖请我去吃肉
    2021-01-17 06:33

    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];
    

    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

提交回复
热议问题