Strange looking UIAlertViews in iOS8
Posted: | Author: Jörn | Filed under: iOS | Tags: iOS8, UIAlertView | 4 Comments »Do you have UIAlertViews that look strange under iOS8? The alert text is bold and clings to the top of the alert container?
Apparently iOS8 does not tolerate setting the UIAlertView’s title to nil. When you set it to an empty string instead, the UIAlertView looks like it should.
So instead of doing this:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:@"Hello World!"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
Do this:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""
message:@"Hello World!"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
The funny thing is that with an UIAlertSheet the behavior is opposite: passing an empty string as title results in an empty title section on top of the UIActionSheet. Passing nil for the title fixes this.
1
Tim S.said atThanks for this! I had to fix both UIAlertViews and UIActionSheets in my app. This doesn’t seem like intended behavior though. Do you think this might change with subsequent 8.x releases?
2
Jörnsaid atHi Tim,
thanks for your comment! The behavior of the UIAlertView definitely looks like a bug. So Apple will probably fix that in one of the next releases. The behavior of the UIActionSheet does not look buggy, but it does not really make sense. Why should you want an empty title section in your UIActionSheet if you don’t provide a title?
Best regards,
Jörn
3
Tim S.said atThanks for the reply. Yes, I agree on the ActionSheet. Seemed odd to lose a whole row to blank space. Hopefully when they fix it, it doesn’t require a change on my part. nil or an empty string I’d hope would render the same desired outcome.
4
Jörnsaid atI filed 2 radars for these issues:
rdar://18411010 (UIAlertView)
rdar://18411081 (UIActionSheet)