UINavigationBar appearance and Facebook-Sheet Bug
Asked Answered
D

2

1

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! :)

Darciedarcy answered 27/4, 2013 at 20:7 Comment(0)
R
2

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];
Rohn answered 27/4, 2013 at 20:50 Comment(1)
Thanks a lot for your answer! I fixed the problem with: [UINavigationBar appearanceWhenContainedIn:[UINavigationController class], nil];Darciedarcy
L
2

Appearance settings are applied to all the controls that are displayed after you define your settings. So in your case every navigation bar will use your background image. You can fix your problem by changing the appearance settings (black color) before you push the view controller that should have the black nav bar and set them back before you pop the view controller with the black nav. I had a similar problem in on of my projects and what I mentioned above solved the problem.

P.S Sorry for any spell mistakes and for the lack of source code, i'm on the road and i'm typing from my phone ;)

Lichenology answered 27/4, 2013 at 20:36 Comment(1)
thanks, but in my case this is a waaay to much work. I fixed it as mention above :)Darciedarcy
R
2

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];
Rohn answered 27/4, 2013 at 20:50 Comment(1)
Thanks a lot for your answer! I fixed the problem with: [UINavigationBar appearanceWhenContainedIn:[UINavigationController class], nil];Darciedarcy

© 2022 - 2024 — McMap. All rights reserved.