触摸导航栏时关闭 UIPopOverScreen
我有这个 UIPopOverScreen,当我按下导航栏按钮时会显示。 每当我触摸弹出屏幕之外的任何内容时,我都想忽略它。 它可以部分工作,但在触摸导航栏时不会消失,该导航栏已内置于调用弹出屏幕的 VC 中。
我尝试了多种方法让它消失,但还没有奏效。 我设置时得到的最佳结果:
self.popOverController.passthroughViews = nil;
它按照我想要的方式工作,但是通过设置它,您必须按导航栏两次才能使其再次响应。
我很想听听您对干净解决方案的想法。
I have this UIPopOverScreen that shows when I press a NavigationBar Button.
The problem I want to dismiss it whenever I touch anything outside that popoverscreen.
It partly works but it doesn't dismiss when touching the navigationbar which has been built into the VC that calls the popoverscreen.
I've tried several options to make it disappear but it just hasn't worked yet.
The best results I've gotten when I set:
self.popOverController.passthroughViews = nil;
It worked as I wanted but by just setting this you have to press the navigationbar twice to make it respond again.
I would love to hear your thoughts about a clean solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加 UITapGestureRecognizer 来对导航栏上的点击做出反应怎么样?保存对活动 Popover 的引用,并在导航栏收到点击时通过调用方法将其关闭。
How about adding a UITapGestureRecognizer to react to a tap on the navigation bar? Save a reference to the active Popover and dismiss it by calling a method when the navigation bar receives a tap.