Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAlertController status bar not dimming and tint color issues

I am migrating from using UIAlertView to the UIAlertController introduced in iOS 8. However, I am seeing a few strange view issues I don't see when using UIAlertView. First, when displaying an alert, the status bar text doesn't dim:

Status bar not dimmed

Also, after displaying the status bar, the back arrow in the UINavigationController is now set to the application's tintColor rather than the white tintColor I set for the UINavigationBar. This affects other UINavigationBar elements throughout the application, such as Add (+) buttons and Edit buttons. Before displaying the UIAlertController, all of the bar button items were showing up as white.

wrong tint color for back button

wrong tint color for edit and back button

I'm at a loss here. My code for displaying the alert is very straightforward:

UIAlertController *view = [UIAlertController alertControllerWithTitle:VALIDATION_TITLE message:text preferredStyle:UIAlertControllerStyleAlert];
[view addAction:[UIAlertAction actionWithTitle:VALIDATION_BUTTON_OK style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:view animated:YES completion:nil];
like image 293
Dan Avatar asked Feb 01 '16 17:02

Dan


1 Answers

So, when dealing with diplaying UIAlertControllers when I don't have a handle to the displaying UIViewController, I found the following code on stackoverflow:

https://stackoverflow.com/a/30941356/3434545

If I use the show: method, which invokes a new UIWindow and presents the UIAlertController from that new window, I don't have any of the UI side effects that I see above when displaying an alert.

If someone knows why this is happening, please still answer this question because this is a fairly hacky workaround!

like image 94
Dan Avatar answered Oct 18 '22 08:10

Dan