Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customized back button appears on UIImagePickerController

I use the following code to customize the back button on the navigation bar throughout my application:

UIImage *backButton = [[UIImage imageNamed:@"backButton"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
UIImage *backButtonOn = [[UIImage imageNamed:@"backButton_on"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton
                                                  forState:UIControlStateNormal
                                                barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonOn
                                                  forState:UIControlStateHighlighted
                                                barMetrics:UIBarMetricsDefault];

It's working great except when I present a UIImagePickerController and enter an album in the photo library the back button is also the customized back button. How can I get back the original back button in the image picker?

like image 876
SolidSun Avatar asked Nov 15 '12 20:11

SolidSun


2 Answers

 [[UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil] setBackButtonBackgroundImage:[UIImage imageNamed:@"blank-button"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

this is the correct way

like image 54
iMeMyself Avatar answered Nov 17 '22 13:11

iMeMyself


Try using this:

    [[UINavigationBar appearanceWhenContainedIn:[YourClassThatsNotAUIImagePicker class], nil] setBackButtonBackgroundImage:someOtherImage forBarMetrics:UIBarMetricsDefault];

That should limit your appearance setting to only the classes you list and therefore leave the UIImagePickerController alone.

like image 4
HackyStack Avatar answered Nov 17 '22 13:11

HackyStack