I styled a UIBarButtonItem using Appearance API like the following
[[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
This works great all over the app. The problem is, that this also changes the buttons in video views of YouTube videos that get loaded if you click a YouTube video in a uiwebview.

adding code like this:
[[UIBarButtonItem appearanceWhenContainedIn:[MPMoviePlayerViewController class], nil] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
doesn’t change anything (because it seems the YouTube thing isn’t just a MPMoviePlayerViewController.
If I understand correctly, I am also not allowed to change the buttons of the YouTube view (and also I don’t want this).
Any ideas how I could stop setting custom bar button images on this YouTube video view?
Here is the sample project if you want to take a closer look: https://dl.dropbox.com/u/80699/BarItemsSample.zip
I believe I have come up with the most efficient solution currently available for this problem. Unfortunately the Youtube video player is of a private class called
MPInlineVideoViewController. It is not possible to use the appearance proxy on this class, which would kind of be a hack anyway.Here is what I came up with. I coded it in a way that it could be used in more than one places and could also be used to solve other Appearance proxy issues, such as the back and next UIBarButtonItems when filling out a form in a UIWebView.
In the above code we toggle the appearance styles back to their default values so when the YouTube player is loaded, it uses the default styles. The current ViewController has already loaded so it will have the styled appearance.
When the YouTube player dismisses, the current ViewController will not be reloaded, thus maintaining the styling. When the current ViewController disappears, the styled appearances are turned back on.