单击导航栏时 UIPopoverController 不会关闭
当点击 rightBarButton 时,会出现一个 UIPopoverController。
问题是:当单击导航栏时,此 UIPopoverController 不会关闭。
为什么?并且有办法解决吗? 我尝试过搜索,但找不到任何与此相关的信息。
提前致谢。
When clicking on a rightBarButton, a UIPopoverController will present.
The problem is: when clicking on the NavigationBar, this UIPopoverController does not dismiss.
Why? And is there a way to resolve it?
I have tried to search, but can't find anything about this.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
UIPopoverController
似乎在呈现导航栏时将其添加到其passthroughViews
数组中。我能够通过在呈现弹出窗口后立即将 passthroughViews 重新设置为空数组来解决该问题。UIPopoverController
seems to add the navigation bar to itspassthroughViews
array when it is presented. I was able to solve the problem by re-settingpassthroughViews
to an empty array immediately after presenting the popover.从栏按钮启动时,您可以简单地执行此操作
When launching from a bar button you can simply do this
导航栏上的项目将自动添加到 popoverViewController 的 passthroughViews 中。它发生在弹出窗口出现后。所以之后你需要清除 passthroughViews 。
对于iOS 8,我们可以从UIViewController.popoverPresentationController获取popoverController,在此之前,我们可以从UIStoryboardPopoverSegue获取popoverController。
在您的视图控制器中,将视图控制器呈现为弹出窗口。
在您的视图控制器中,它显示为弹出窗口。
Items on your navigation bar will be automatically added to popoverViewController's passthroughViews. It happens after the popover shows up. So you need to clear passthroughViews after that.
And for iOS 8, we can get popoverController from UIViewController.popoverPresentationController, before that, we can get popoverController from UIStoryboardPopoverSegue.
In your view controller presents a view controller as popover.
In your view controller that is presented as popover.
UIPopoverController 的文档
指出:当从栏按钮项呈现弹出窗口时,导航栏将添加为
passthroughViews
之一。也许尝试在弹出窗口控制器上设置一个空数组作为
passthroughViews
属性。The documentation for
UIPopoverController
states:The navigation bar is added as one of the
passthroughViews
when the popover is presented from a bar button item.Perhaps try settings an empty array as the
passthroughViews
property on your popover controller.您将此鳕鱼放在任何其他操作上或完成选择后或在弹出窗口中提供一些关闭按钮并完成 uy yhing,
You put this cod on any other action or After completing the selection or provide some close button in the popover and accomplish uy yhing,
据我所知,这是预期的行为。 iBooks 中书架上的弹出窗口的行为如下。呈现弹出窗口时保留对弹出窗口的引用,然后在点击导航栏中的任何按钮时将其关闭。
This is expected behavior as far as I can tell. The popover on the bookshelf in iBooks behaves like this. Retain a reference to the popover when you present it, and then dismiss it if any of the buttons in the navigation bar are tapped.