我希望将物体放在触摸抬起位置(离屏幕)。
这将用于实现拖放,我有这些方法可以覆盖:
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
在touchesEnded中使用[[touches anyObject] view]
:withEvent:给出了我第一次触摸的UIView对象,但不是我释放触摸的位置。
使用[[touches anyObject] locationInView:self.view]
确实为我提供了触摸释放位置的位置,但我必须将坐标映射到UIView。
答案 0 :(得分:0)
这个问题的答案用不同的问题回答。
@Ronak Chaniyara回答:https://stackoverflow.com/a/16329436/3920809