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:
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.
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];
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With