PIXEL
DOCK

I like the smell of Swift in the morning…

Strange looking UIAlertViews in iOS8

Posted: | Author: | Filed under: iOS | Tags: , | 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.