iphone - 简单的 UITapGestureRecognizer。 IBAction 未触发

标签 iphone objective-c ios storyboard uigesturerecognizer

我有一个 UITapGestureRecognizer 链接到一个 IBAction。我只是想确认 IBAction 方法调用。对于 UITapGestureRecognizer,在 Storyboard 中,我有一个指向 gestureRecognizers 的引用 socket 集合,并发送操作 tapGesture: 链接到我的 ViewController。

.h代码:

- (IBAction)tapGesture:(UITapGestureRecognizer *)sender;

.m代码:

- (IBAction)tapGesture:(UITapGestureRecognizer *)sender {
     NSLog(@"Tapped");
}

我错过了什么?为什么 tapGesture: 没有触发?

enter image description here

最佳答案

从您的屏幕截图看来,手势识别器已添加到 View Controller ,而不是 View 。您只需将手势识别器拖到 View 上,它就会正确添加。

关于iphone - 简单的 UITapGestureRecognizer。 IBAction 未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10605711/

相关文章:

ios - json对象中的html标签

iphone - 应用程序未运行时处理远程通知时崩溃

iphone - 如何在 iphone 中通过电子邮件发送 .caf 文件?

ios - 类型标识符为 "com.apple.pkpass"的 NSItemProvider

iphone - HTTPS + ASIHTTPRequest 会被 App Store 批准吗?

objective-c - 如何使用 objc_method_family 注释 Objective C 属性?

ios - 调用 touchesEnded : when tapped but not swiped

ios - 如何将 NSMutableArray 添加到 NSMutableArray Objective-c

ios - 永远不会调用 UITextField drawTextInRect

ios - 是否有用于广告标识符使用的 info.plist key