disable UIAppearance-API happen on RemoteViewControllers

ios, ios6, iphone, objective-c, uiappearance

Solution

Your best bet is really to subclass one thing or the other. Otherwise you'll be undoing styles everywhere. I'll do it in one of two ways:

One is to subclass `UINavigationController` and style the `UINavigationBar` contained by that class:

UINavigationBar *navigationBarProxy = [UINavigationBar appearanceWhenContainedIn:[MyNavigationController class], nil]; // 
[navigationBarProxy setBackgroundImage:navigationBarBackgroundImage forBarMetrics:UIBarMetricsDefault];
// and so on

Another method is to subclass `UINavigationBar` instead, set the appearance for that class, and instantiate your `UINavigationController` this way:

UINavigationController *navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[MyNavigationBar class] toolbarClass:nil];
// navigationController now has a navigationBar of your preferred type

Problem

So i am styling all my views using the apprearance api. F.e. i style my `UINavigationBar` using: ``` [[UINavigationBar appearance] setBackgroundImage:navigationBarBgImage forBarMetrics:UIBarMetricsDefault]; ``` i want to use the advantage of the appearance api of styling all my `UINavigationBar`s in one single place (because i have multiple of them), so i don't want to do some subclassing only because of styling reasons. i also popup some `MFMessageComposeViewController`s and a `SLComposeViewController` to post to imessage or facebook. my problem here is, if i try to select albums on facebook or select contacts on imessage modalview, this happens: see the recursive description of the imessage modal view: ``` $0 = 0x1f1f1320 <UIWindow: 0x1e5c8900; frame = (0 0; 320 568); layer = <UIWindowLayer: 0x1e5c8a00>> | <UILayoutContainerView: 0x1e592860; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x1e592910>> | | <UINavigationTransitionView: 0x1f1c88a0; frame = (0 0; 320 568); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x1f1c8960>> | | | <UIViewControllerWrapperView: 0x1f1ee090; frame = (0 20; 320 548); autoresize = W+H; layer = <CALayer: 0x1f2f9560>> | | | | <UIView: 0x1f2f3d20; frame = (0 0; 320 548); autoresize = W+H; layer = <CALayer: 0x1f2f3d80>> | | | | | <_UISizeTrackingView: 0x1f2effd0; frame = (0 0; 320 548); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x1f2f00b0>> | | | | | | <_UIRemoteView: 0x1f2f01e0; frame = (0 0; 320 568); transform = [0.5, -0, 0, 0.5, -0, 0]; userInteractionEnabled = NO; layer = <CALayerHost: 0x1f2f0330>> ``` any ideas whats the best to switch back there to default mode?

Original source