1
-(BOOL)prefersStatusBarHidden
{
    return YES;
}

- (IBAction)PhotoImportAction:(id)sender
{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = NO;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
        [self presentViewController:picker animated:YES completion:nil];
    else
    {
      popover=[[UIPopoverController alloc]initWithContentViewController:picker];
              popover.delegate=self;

        [popover presentPopoverFromRect:PhotoImportButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

    }


}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *selectedImage=info[UIImagePickerControllerOriginalImage];
    VisualEffectImageVIew.image=selectedImage;
    BackgroundImageView.image=selectedImage;
    ForegroundImageView.image=selectedImage;
   if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
    {
        [picker dismissViewControllerAnimated:YES completion:nil];
    }
    else
    {

        [popover dismissPopoverAnimated:YES];

  }
}
-(void)viewWillAppear:(BOOL)animated
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES];

}
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
}

Above code is pretty straightforward, everything works fine ,except viewWillAppear method that doesn't work on iPad after dismissal of UIPopoverController , so we tried using popoverControllerDidDismissPopover method but the statusBar is still visible. Any solution is appreciated.

USERX2DX
  • 207
  • 2
  • 8

4 Answers4

1

From your code what I see is you have not set UIPopoverController's delegate. add following line

 popover.delegate = self

before presenting the popover. Hope this works.

Vivek Molkar
  • 3,910
  • 1
  • 34
  • 46
  • connected with delegate but still the method's not called. – USERX2DX Apr 27 '15 at 11:02
  • Make sure your `ViewController` conforms `` protocol. – Vivek Molkar Apr 27 '15 at 11:04
  • the protocol is included otherwise I would get errors. – USERX2DX Apr 27 '15 at 11:11
  • I saw your edited code you assign `popoverCon.delegate=self;` there is no `popoverCon` in the picture. I think it should be `popover.delegate=self`. Correct me if I am missing something. – Vivek Molkar Apr 27 '15 at 11:13
  • in your popoverviewcontroller do you call `dismissPopoverAnimated:` method? if that is the case `popoverControllerDidDismissPopover:` won't be called. Here is the [reference](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPopoverControllerDelegate_protocol/index.html#//apple_ref/occ/intfm/UIPopoverControllerDelegate/popoverControllerDidDismissPopover:) – Vivek Molkar Apr 27 '15 at 11:26
  • Yes in didFinishPickingMediaWithInfo method() – USERX2DX Apr 27 '15 at 11:28
  • Coming back to your problem. You should find some other better place to hide the `statusBar` or call the `popoverControllerDidDismissPopover:` method yourself. :) – Vivek Molkar Apr 27 '15 at 11:34
  • Yes, the delegate method will not be automatically called. So what you can do is call the method on your own after dismissing the popover in the popovercontroller. – Vivek Molkar Apr 27 '15 at 11:40
1

According to apple's documentation the method popoverControllerDidDismissPopover will not be called if popoverController is dismissed programatically.You can manually call the popoverControllerDidDismissPopover method.

[self popoverControllerDidDismissPopover:popoverController];
USERX2DX
  • 207
  • 2
  • 8
0

Add following line in viewdidload

[[UIApplication sharedApplication] setStatusBarHidden:YES
                                            withAnimation:UIStatusBarAnimationFade];

and add new method

 - (BOOL)prefersStatusBarHidden {
          return YES;
  }

also change info.plist file View controller-based status bar appearance" = NO

vijeesh
  • 1,317
  • 1
  • 17
  • 32
  • didn't work and yes we have set status bar is initially hidden to YES and view controller based status bar to NO. – USERX2DX Apr 27 '15 at 09:39
0

You didn't set the delegates of the popover. Please set it and check if delegate method is working or not...

Hope it helps :)

Tejvansh
  • 676
  • 4
  • 9
  • See my code carefully bro I have used it ,but it works only for uiimage picker controller and does not work for uipopovercontroller. – USERX2DX Apr 27 '15 at 10:38