detect when UIPopoverController has finished prese

2019-02-25 01:12发布

I have the UIImagePickerController as a content View Controller for the UIPopoverController. I need to detect when the popover has just finished presented (has just showed up). UIPopoverController does not have any delegate for this. I can't seem to find a way to detect the UIImagePickerController as well. (This is for iPad)

Any suggestions?

// UIImagePickerController let's the user choose an image.
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
self.popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
self.popover.delegate = self;
[self.popover presentPopoverFromBarButtonItem:self.openPhotosButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

2条回答
放荡不羁爱自由
2楼-- · 2019-02-25 01:47

The UIImagePickerDelegate is also a UINavigationControllerDelegate.

Your class should implement UINavigationControllerDelegate and include the following:

 -(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
     // [navigationController setNavigationBarHidden:YES];
      [[UIApplication sharedApplication] setStatusBarHidden:YES];  // This one works for me: OP
    }

I've tested this and it hides the navigation bar. I am not sure if doing so conflicts with the HIG though.

查看更多
戒情不戒烟
3楼-- · 2019-02-25 01:54

Thise should help:

  • UIImagePickerControllerDelegate and imagePickerController:didFinishPickingMediaWithInfo:
  • UIPopoverControllerDelegate popoverControllerDidDismissPopover

You have delegates for both

查看更多
登录 后发表回答