- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试找到一种方法,当用户在过滤我的 tableview 的内容后点击屏幕上的其他地方时,立即隐藏键盘。
但不知何故,当我添加 UITapGestureRecognizer 时,我的 TableView 卡住了,无法进一步进入应用程序。
这是我的做法:
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissKeyboard")
self.view.addGestureRecognizer(tap)
func dismissKeyboard() {
view.endEditing(true)
}
我已经在带有 TextField 的 Blank ViewController 上尝试过这个并且它有效。我错过了什么?有没有一种特定的方法可以将 GestureRecognizer 添加到 TableView 中?因为一旦我添加手势,它就会破坏一切。我也尝试使用 resignFirstResponder 得到相同的结果。
有什么建议吗?谢谢!
最佳答案
尝试将 cancelsTouchesInView
变量设置为 false。这默认为 true,通过将其设置为 false,您允许通过手势响应触摸,然后通过手势返回 View ,以便 tableView 也可以响应。
tap.cancelsTouchesInView = false
文档中的讨论摘录:
When this property is true (the default) and the receiver recognizes its gesture, the touches of that gesture that are pending are not delivered to the view and previously delivered touches are cancelled through a touchesCancelled:withEvent: message sent to the view. If a gesture recognizer doesn’t recognize its gesture or if the value of this property is false, the view receives all touches in the multi-touch sequence.
关于ios - GestureRecognizer 不适用于 TableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34358762/
我正在尝试在 iPhone 的 Objective C 中长按一个按钮。 这是我为 GestureRecognizer 编写的代码: UILongPressGestureRecognizer
视网膜设备每侧的像素数是非视网膜设备的两倍。 使用 UIPanGestureRecognizer 时,我可以通过调用 - (CGPoint)velocityInView:(UIView *)view
我的 Storyboard中有此设置。 在我的第一个 ViewController 场景中,我有一个来自 MapBox 的 MapView。我在那里放置了一个文本字段(AddressTextField
我想长按表格 View 单元格,但我收到错误: UIGestureRecognizer.Type' does not have a member named 'state' 这是代码 overrid
我正在尝试使用 gestureRecognizer 使我的单元格可滑动: - (UITableViewCell *)tableView:(UITableView *)aTableView cellFo
我将 gestureRecognizer 与 UIImageView 一起使用。我有两个 UIImageView。我需要在两个 UIImageView 中上传图片。为了打开 UIImagePicker
我在理解 UIGestureRecognizers 时遇到了问题。我现在的目标是拥有一组 GestureRecognizers 来执行不同的任务,例如: override func viewDidLo
通过 UIImageView 的子类初始化后,我有以下代码行: self.userInteractionEnabled = true self.addGestureRecognizer(UITapGe
我有一个带有自定义按钮的 Collection View 。并且有一个可以更改图像及其背景颜色的功能。我的问题:如果我单击它,它适用于每个按钮,我想创建一个可以更改我的 SELECTED 按钮的颜色和
我目前正在使用 cocos2d 构建游戏,但遇到以下问题:我有一个 MenuScene,用户可以在其中开始游戏。当他这样做时,gestureRecognizer 将通过以下方式使用级别进行初始化: C
我在包含多个手势识别器的 View 中添加了一个 subview ,但是当引入此 View 时,当用户在这个新添加的 View 中点击时,手势将不会触发。然而,我要介绍的是一个UIBezierPath
我有以下问题:在我的 iphone 应用程序中,我有一个 UIView 包含 0 到多个 subview 。这些 subview 可能会溢出父 View 并因此被隐藏,它们都是 UIButtons。我
@IBAction func BetPop(sender: UITapGestureRecognizer) { var BetPopVC = self.storyboard?.instanti
我有 2 个 GesturerRecognizer,一个是自定义 3DTouch,另一个是单个 UITapGestureRegognizer。我想做的是,如果你点击一次它执行一个 segue,如果你去
我尝试识别用户在 View 上的点击。我用下面的代码试了一下: override func viewDidLoad() { super.viewDidLoad() let tap =
我正在尝试在我的应用程序上同时检测向上和向下滑动。我有一个 SKScene,我在 func didMoveToView: view 中添加了手势识别器我已设置委托(delegate):UIGestur
我一直在使用 this文章(和其他一些文章)尝试在我的应用程序中实现手势识别,它确实有效。但是,我想做的是检测多个手势;例如,滑动和触摸。我似乎无法确定 MouseUp 事件是由手势结束引起的,还是由
我正在尝试找到一种方法,当用户在过滤我的 tableview 的内容后点击屏幕上的其他地方时,立即隐藏键盘。 但不知何故,当我添加 UITapGestureRecognizer 时,我的 TableV
我尝试结合许多教程来尝试让手势识别器在 mapView 上收到手势后在 tableView 上启动动画(一旦 map 像旧的 uber 应用程序一样移动就会缩小表格)。动画功能,但是一旦动画完成,我收
我有一个 Web View (在 View 内)和一个大部分时间隐藏的工具栏。 这是 ipad 杂志很常见的行为:点击页面会隐藏和显示工具栏,但工具栏默认隐藏。 我正在使用 shouldRecogni
我是一名优秀的程序员,十分优秀!