ios - 无法触发长按手势 [UiView]
问题描述
我对 iOS 和目标 c 非常陌生,我面临的问题是我无法正确地将长按手势识别器注册到我的视图中。我有点困惑,因为我已经以类似的方式添加了一个轻击手势识别器,并且效果很好。这就是我添加长按手势识别器的方式:
UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action: @selector(onTap:)];
UILongPressGestureRecognizer * longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action: @selector(longPress:)];
[_pdfView addGestureRecognizer:longPressGesture];
[_pdfView addGestureRecognizer:tapGesture];
这是我的长按功能:
-(void) longPress:(UILongPressGestureRecognizer *)sender {
NSLog(@"longPress");
}
这是我的头文件:
@interface FLTPDFSandboxController : NSObject <FlutterPlatformView, CustomPdfViewDelegate>
- (instancetype)initWithFrame:(CGRect)frame;
-(void) onTap:(UITapGestureRecognizer *)sender;
-(void) longPress:(UILongPressGestureRecognizer *)sender;
- (UIView*)view;
@end
点击手势对我来说效果很好。这只是一个没有持续触发的长按。事实上,在一些非常罕见的情况下,它会以某种随机的方式触发。
谢谢你。
解决方案
推荐阅读
- java - 有没有办法使用正则表达式处理包含主标题的文本文件中的数据?
- mysql - Mysql查询具体输出
- java - 如何以编程方式在 Android 的现有 xml 中添加按钮
- java - 使用注解的 Java 多模式生成器
- javascript - 在分配变量后的Vue中,它仍然指向旧变量
- python - 列表的 Python 格式(单行)
- google-apps-script - 谷歌脚本格式日期创建不可能的日期
- javascript - 如何创建具有 2 个键和 1 个值的对象?
- python - 是否有相当于 `pip install -t` 的`conda`
- ffmpeg - ffmpeg drawtext 支持藏文字体