触摸外部时隐藏 UITableViewController 中的 UIPickerView
现在我的 UITableViewController 中有 2 个不同的 UIPickerView。我仅在点击表格中的某些单元格时显示它们。我想做的是每当我触摸拾取器外部时隐藏拾取器。是否有委托方法或类似的方法来实现此目的?我更喜欢将控制器保留为 UITableViewController 而不是简单的 UIViewController,因为我在其中一个单元格中有一个 textView,并且在键盘显示后滚动在 UIViewController 中有点太多了。
提前致谢。
Right now I have 2 different UIPickerView in side my UITableViewController. I only show them upon tapping of certain cells in the table. What I'm trying to do is to hide the pickers whenever I touch outside the pickers. Is there a delegate method or something similar to achieve this? I prefer to keep my controller as a UITableViewController instead of a simple UIViewController since I have a textView in one of the cells and scrolling after the keyboard shows is just a bit too much in a UIViewController.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能的解决方案之一是,当点击特定单元格并处理选择器(以显示选择器)时,您可以在表格视图上插入一个名为“MASK View”的视图。 (框架为 self.tableview.frame - yourPicker.frame.size.height )。现在,当您单击此视图时,您可以按如下方式处理它
在 MaskView 类中,您可以按如下方式处理触摸,
您可以在图像中的选取器上看到彩色蒙版视图。当点击时,它会删除选择器。

One of the Possible solutions is that when a particular cell is tapped and you handle picker (to present the picker), you can insert a view called as MASK View over the tableview. (with Frame as self.tableview.frame - yourPicker.frame.size.height ). Now when ever you get any click on this view you can handle it as follows
In the MaskView class you can handle the touch as follows
you can see the colored mask view over the Picker in the image. When tapped it removes picker.
