本文介绍了从其contentViewController中取消UIPopoverController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您想要关闭popover - 例如,从弹出框的contentViewController中的按钮,您必须 -

If you want to dismiss a popover -- for example, from a button within the popover's contentViewController you must --


  1. 创建引用要由创建它的视图控制器持有的popover

  2. 从contentViewController创建一个通知,让拥有的视图控制器知道它应该被关闭,或者替代地创建一个委托

  3. 调用 dismissPopover:animated


  4. 在弹出窗口可以关闭时发送通知或委托消息
  5. code>当调用通知或委托方法时
  1. Create a reference to the popover to be held by view controller which creates it
  2. Create a notification from the contentViewController to let the owning view controller know that it should be dismissed, or alternately create a delegate for the same purpose
  3. Send the notification or delegate message when the popover is ready to be dismissed
  4. Call dismissPopover:animated when the notification or delegate method is called

同时,从 UIViewController 您可以访问模式视图控制器,父视图控制器,导航控制器,分割视图控制器,选项卡栏控制器,搜索显示控制器,子视图控制器,呈现视图控制器和呈现视图控制器。

Meanwhile, from a UIViewController you can access the modal view controller, the parent view controller, the navigation controller, the split view controller, the tab bar controller, the search display controller, the child view controllers, the presenting view controllers, and the presented view controllers.

有没有更好的方法来做这个popover的contentViewController?

Is there a better approach to do this from popover's contentViewController?

推荐答案

p>不幸的是,你必须创建一个弱属性引用 UIPopoverController ,因为没有办法从内容视图控制器访问它。

Unfortunately, you'll have to create a weak property reference to said UIPopoverController as there's no way to access it from within the content view controller.

我很惊讶UIViewControllers如何访问模态视图控制器,父视图控制器,导航控制器,分割视图控制器,标签栏控制器,搜索显示控制器,以及从iOS 5,子视图控制器以及呈现和呈现控制器,但不是popover控制器(授予popovers不是 UIViewController s但仍然) 。

I was surprised how UIViewControllers can access the modal view controller, the parent view controller, the navigation controller, the split view controller, the tab bar controller, the search display controller, and as of iOS 5, the child view controllers as well as presenting and presented controllers...but not the popover controller (granted popovers aren't UIViewControllers but still).

技术上,有一个私人的,未记录的方法来检索UIViewController所在的popoverController ...我不知道为什么他们从来没有公开它,因为它应该

Technically, there's a private, undocumented method to retrieve the popoverController that the UIViewController is in...I have no idea why they never made it public given that it should be exactly the same as any of the above controllers.

虽然即使在私有的,未记录的世界中,也没有等同于 dismissModalViewcontrollerAnimated:。你仍然必须得到那个参考,然后以这种方式解雇。

Though even in the private, undocumented world, there's no equivalent to dismissModalViewcontrollerAnimated:. You'll still have to get that reference then dismiss it that way.

这篇关于从其contentViewController中取消UIPopoverController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 03:53