更改手势识别器位置?
我有一个手势识别器来检测 UIImageView 上的点击,但是当 iPad 的方向发生变化时,我会强制更改图像的位置,但这会导致手势识别器错误地重新定位。我该如何解决这个问题?
编辑:
strapTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(strapTap:)];
[(UITapGestureRecognizer *)strapTap setNumberOfTapsRequired:1];
strapTap.delegate = self;
[leatherButtonedStrap addGestureRecognizer:strapTap];
上面是我如何设置手势,将其添加到我的 UIImageView 中。然而,可能会引起轰动的是,我将 this 视图添加到我的主视图中,将其删除,然后在用户按下某个按钮时重新添加它。除非你看到整个班级,否则你很难理解发生了什么,但请告诉我这是否足以继续下去。
I have a gesture recogniser to detect a tap on a UIImageView, however I force a position change of the image when the orientation of the iPad changes but this causes the gesture recogniser to repositioned incorrectly. How can I resolve this?
EDIT:
strapTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(strapTap:)];
[(UITapGestureRecognizer *)strapTap setNumberOfTapsRequired:1];
strapTap.delegate = self;
[leatherButtonedStrap addGestureRecognizer:strapTap];
This above is how I setup the gesture, adding it to my UIImageView. However, something which might cause a stir is that I add the this view to my main view, remove it and then re-add it when the user presses a certain button. Hard for you to understand whats happening unless you saw the entire class, but let me know if this is enough to go on or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保当您在 bandTap: 中调用 locationInView: 时,将 LeatherButtonedStrap 作为参数发送:
以便该位置相对于 LeatherButtonedStrap 的坐标系,而不是相对于超级视图的坐标系。
Make sure when you're calling locationInView: in strapTap: to send the leatherButtonedStrap as the parater:
So that the location is relative to leatherButtonedStrap's coordinate system an not it's superview's.