Search code examples
iphoneobjective-ctouchesmoved

touchesMoved not registering location


Touchesmoved is not picking up the location of my cursor.

I have this code:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint touchPoint = [[touches anyObject] locationInView:svEditView];
    [((UIView *)[[svButtonsArray objectAtIndex:svTouchDownID] objectAtIndex:1]) setCenter:touchPoint];
    NSLog(@"Touches moved");
    NSLog(@"1. %i", touchPoint.x);
    NSLog(@"2. %i", touchPoint.y);
}

So the UIView which it's told to drag around does move to the correct location, but on the NSLog it returns 0 every time, for the touchPoint. Any ideas why?

EDIT: Changing it to %f works, but it is a full number with a big trail of .000000 on the end, so not sure why it wouldn't work with %i.


Solution

  • touchePoint.x and .y are float not int. You need to print with %f.

    List output that you are getting with %f.