【问题标题】:detect when UIPopoverController has finished presented UIImageViewcontroller检测 UIPopoverController 何时完成呈现 UIImageViewcontroller
【发布时间】:2013-09-20 19:46:44
【问题描述】:

我将 UIImagePickerController 作为 UIPopoverController 的内容视图控制器。我需要检测弹出框何时刚刚完成呈现(刚刚出现)。 UIPopoverController 对此没有任何委托。我似乎也找不到检测 UIImagePickerController 的方法。 (这适用于 iPad)

有什么建议吗?

// 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];

【问题讨论】:

  • 您正在寻找类似 viewDidLoad 或 viewDidAppear 的东西? (实现 UIViewController 时覆盖的方法)。
  • 可以,但是本例中popover的内容视图控制器是UIImagePickerController。
  • 我明白了……你不能覆盖 UIImagePickerController,所以 viewDidLoad 方法不起作用。你想达到什么目的?可能还有另一种方法。
  • 当 UIImagePickerController 出现时,我需要隐藏状态栏。 (iOS 7 相关)
  • 好的,明白了。 ImagePickerDelegate 也是一个 UINavigationControllerDelegate,因此它包括 -(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated - 在正确的时间调用。只需让你的类也实现 UINavigationControllerDelegate。

标签: ios uiimagepickercontroller uipopovercontroller


【解决方案1】:

UIImagePickerDelegate 也是一个 UINavigationControllerDelegate。

你的类应该实现 UINavigationControllerDelegate 并包括以下内容:

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

我已经对此进行了测试,它隐藏了导航栏。我不确定这样做是否会与 HIG 冲突。

【讨论】:

  • 这个委托工作得很好。当出现 ImagePickerView 和点击任何相册时,它会被调用。所以它是隐藏状态栏的正确位置。谢谢。
  • 尝试了其他一些解决方案,但都不能很好地工作。这是完美的!
【解决方案2】:

这应该有帮助:

  • UIImagePickerControllerDelegate 和 imagePickerController:didFinishPickingMediaWithInfo:
  • UIPopoverControllerDelegate popoverControllerDidDismissPopover

你有两个代表

【讨论】:

  • 哦 - 你是如何展示它的 - 你能用你展示它的代码更新问题吗?你做一些动画或其他什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-07-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多