Search code examples
iphonetouchesmoved

touchesMoved <-- I can only see the y point


Why can I only see the "y" component of nowPoint changing, ["x" component is always "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);
}

Solution

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

    Change this to...

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