iosobjective-cipadcocoa-touchmodalviewcontroller

REALLY strange app color behavior?


On appDidFinishLaunchingWithOptions, I tint my entire app red with the following code.

self.window.tintColor = [UIColor otfRedColor];

This works perfectly, and when my app loads, all the navigation bar items are red. A is my root view controller.

I have 3 view controllers, a, b, and c. A pulls up a modal presentation view sheet of b which pulls up a full modal view of c. When C is pulled up, the bar button items on navigation bar are all tinted gray, this shouldn't be happening because I didn't alter any tint or color in any way after the app delegate tinted the window. I then use

[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];

to dismiss VC c and b, but now my ENTIRE app is tinted gray. I haven't used any tint code at all since the app delegate, why does this happen? When I go from A to B again, that navigation bar items are still red???

Code to pull up view controller B from A:

AthleteAdd *addAthlete = [self.storyboard instantiateViewControllerWithIdentifier:@"addAthlete"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addAthlete]; 
addAthlete.delegate = self;
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil]; 

Code to pull up C from B:

    MedicalReleaseVC *medRelease = [self.storyboard instantiateViewControllerWithIdentifier:@"showMedRel"];
    medRelease.delegate = self;
    [self presentViewController:medRelease animated:YES completion:nil];

Does anyone know why this happens, or have an idea? I have tried tinting the third view controller as red 3 separate ways and it still remained gray, then when everything is dismissed my entire app is gray. Please help!!

EDIT:

If it helps, the way I solved this problem was by setting the following in my appdelegate.m

 self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;

Solution

  • I think this is a bug in iOS7's handling of tintAdjustmentMode when opening and closing sheets and popovers. I've seen this bug happen in Apple's native mail app, where the bar button items become gray, or conversely, they no longer turn to gray once a popover shows up.

    To debug this further, I suggest subclassing one of your views (or the window directly) and implementing tintColorDidChange. Log the value of tintAdjustmentMode there. I fear this is what is causing your gray tint issues.

    One solution would be to force UIViewTintAdjustmentModeNormal but this would have the effect of no dimming when opening a popover or a sheet.