使用 Option/Alt 键在 iOS 模拟器上模拟捏合
有人在 UITableView 上的 iOS 模拟器中捏合时遇到过问题吗?我有这段代码:
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
[self.tableView1 addGestureRecognizer:pinch];
[pinch release];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouch:)];
[self.tableView1 addGestureRecognizer:tap];
[tap release];
在我的 viewDidLoad 方法中。在我的handlePinch: 和handleTap: 方法中,我只是简单地使用NSLog(@"pinched") 或@"tapped"。水龙头可以工作,但捏合却不起作用。模拟器中是否存在错误,或者我没有为 UITableView 正确模拟它? (按住两个圆圈的 option 键,单击鼠标,然后拖动以模拟捏合)
编辑: 我为 tableView 选择了 multiTouchEnabled,但它无法识别捏合操作。但是,如果我更改外部容器 UIView 并将捏手势添加到 UIView,那么它似乎可以工作。但我不认为如果外部 UIView 没有根据文档寻找捏手势,它就不应该起作用。
Has anyone had problems with pinching in the iOS simulator on a UITableView? I have this code:
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
[self.tableView1 addGestureRecognizer:pinch];
[pinch release];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouch:)];
[self.tableView1 addGestureRecognizer:tap];
[tap release];
in my viewDidLoad method. In my handlePinch: and handleTap: methods, I simply NSLog(@"pinched") or @"tapped". The tap works, but the pinching does not. Is there a bug in the simulator, or am I not simulating it correctly for UITableView? (hold option key for the two circles, click on the mouse, then drag to simulate pinching)
Edit:
I selected multiTouchEnabled for the tableView and it does not recognize the pinch. However if I change the outer container UIView and add the pinchgesture to the UIView, then it seems to work. But I don't think that it shouldn't work if the outer UIView is not looking for the pinchgesture according to the documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是 XIB,则
multipleTouchEnabled
可能为NO
。将其设置为YES
即可进行捏合操作。If you are using a XIB, it's likely that
multipleTouchEnabled
isNO
. Set it toYES
for pinch to work.