6

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];
Dan
  • 468
  • 1
  • 4
  • 19
  • when u press ok on alert, the alert dismisses, and then the back arrow is dimmed ? Can you show the code related to the back button ? – Teja Nandamuri Feb 01 '16 at 18:20
  • The back arrow isn't actually dimmed; it is set to the global `tintColor` which is greenish/blue. The back arrow doesn't show that color immediately, but will show the new `tintColor` when I toggle away and back to the screen via the tab bar at the bottom. There really isn't any code related to the back button... it is a regular `UINavigationController`. – Dan Feb 01 '16 at 19:14
  • is it happened after u dismiss the alert ? – Teja Nandamuri Feb 01 '16 at 19:22
  • Yes, but again not until I navigate away from my view controller and back to it. – Dan Feb 01 '16 at 19:37

1 Answers1

1

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!

Community
  • 1
  • 1
Dan
  • 468
  • 1
  • 4
  • 19