我正在使用这种方法在视图中移动我的对象:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
在这个方法中,我接下来写了:
NSLog(@"event: %@", event);
并得到这个结果:
event: <UITouchesEvent: 0x310d00> timestamp: 5277.16 touches: {(
<UITouch: 0x3f1110> phase: Moved tap count: 1 window: <UIWindow: 0x3117d0; frame = (0 0; 768 1024); layer = <UIWindowLayer: 0x30cb20>> view: <UIView: 0x330520; frame = (0 0; 768 1024); transform = [0, -1, 1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x330550>> location in window: {279, 677} previous location in window: {305, 694} location in view: {347, 279} previous location in view: {330, 305},
<UITouch: 0x4a1a710> phase: Stationary tap count: 1 window: <UIWindow: 0x3117d0; frame = (0 0; 768 1024); layer = <UIWindowLayer: 0x30cb20>> view: (null) location in window: {412, 89} previous location in window: {413, 89} location in view: {412, 89} previous location in view: {413, 89}
)}
在这个日志中,我可以看到我所有的触摸(现在这是两次触摸)。
我的问题是如何取得联系?
这需要移动我的对象。
现在我正在使用这个:
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
但是当我移动我的对象时,我会得到所有的触摸值。如何处理第一次触摸?
非常感谢!