touchesMoved< - 我只能看到y点

时间:2011-05-25 03:38:16

标签: iphone touchesmoved

为什么我只能看到nowPoint更改的“y”组件,[“x”组件始终为“0”] ??

- (void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event {
    [super touchesMoved:touches withEvent:event];

    CGPoint nowPoint = [[touches anyObject] locationInView:self.view];
    CGPoint prevPoint = [[touches anyObject] previousLocationInView:self.view];

    NSLog(@"x %d,   y %d", nowPoint.x, nowPoint.y);
}

1 个答案:

答案 0 :(得分:3)

NSLog(@“x%d,y%d”,nowPoint.x,nowPoint.y);

将此更改为...

NSLog(@"x %0.02f,   y %0.02f", nowPoint.x, nowPoint.y);