Search code examples
iosfacebookuinavigationbaruiappearance

UINavigationBar appearance and Facebook-Sheet Bug


I use the following code in my appdelegate:

UINavigationBar *navigationBar = [UINavigationBar appearance];
[navigationBar setBackgroundImage:[[UIImage imageNamed:@"top_bar"] stretchableImageWithLeftCapWidth:5 topCapHeight:5] forBarMetrics:UIBarMetricsDefault];
[navigationBar setBackgroundImage:[[UIImage imageNamed:@"top_bar_scape"] stretchableImageWithLeftCapWidth:5 topCapHeight:5] forBarMetrics:UIBarMetricsLandscapePhone];

Everything works fine but i got a weird Bug, when i open the iOS6 Facebook Sharing-Sheet and open the audience-list (or album list doesnt matter): The Navigationbar is rendered with my top_bar-Image. See screens below:

Normal without my appearance changes <- Normal without my appearance changes Buggy with my appearance changes <- Buggy with my appearance changes

Any idea how avoid this bug? Thanks! :)


Solution

  • Appearance changes made using the UIAppearance methods are global - meaning they take effect everywhere. This can be very very helpful or very very annoying.

    One way you could try to fix this problem is either use

    [[UINavigationBar appearanceWhenContainedIn:...
    

    or, you could make a custom subclass of the navigation bar, and have your appearance changes applied only to it:

    [[MYNavigationBar appearance] setSomething:aThing];