2

UIImagePickerController, presented in a popover, does not change navigationBar background image.

I call this code on touch of a button:

    picker = [[UIImagePickerController alloc] init];
    picker.allowsEditing = YES; 
    picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];

    popover = [[UIPopoverController alloc]initWithContentViewController:picker];
    [popover presentPopoverFromRect:self.holderRect inView:self.container permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

I also have the following implementation:

 - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if ([navigationController isKindOfClass:[UIImagePickerController class]])
    {
        UIImage* navBarImage = [UIImage imageNamed:@"imagePickerNav2.png"];
        [navigationController.navigationBar setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
    }   
}

As you would expect, the picker's navigationBar image should be changed to navBarImage. This doesn't happen, exactly. The first view that is displayed in the popover shows thumbnails of all the images and videos on the device. The navigationbar still has the standard ios7 background. When I select a video, another view/VC is presented within the popover. This VC has the left back button that says Camera Roll, a title: Choose Video and a button: Use. The navigation bar here does have navBarImage as the bgimage of the navbar. When I tap the back Camera Roll button, this VC is popped and the popover now shows the original VC with thumbnails of images and videos on the device. Except now, the navigationbar background is changed to navBarImage.

Here is what I have tried and hasn't helped:

  • Setting popover.contentViewController's navbar bg image before/after it is presented.
  • Setting picker's navbar bg image before/after popover is presented.
  • Changing forBarMetrics in setBackGroundImage method
  • Trying the above in

    - (void)navigationController:(UINavigationController *)navigationController **did**ShowViewController:(UIViewController *)viewController animated:(BOOL)animated
    
JoshieSimmons
  • 2,643
  • 2
  • 13
  • 22
Zia
  • 14,442
  • 7
  • 39
  • 57

0 Answers0