Can iPad/iPhone Touch Points be Wrong Due to Calibration?

Posted by Kristopher Johnson on Stack Overflow See other posts from Stack Overflow or by Kristopher Johnson
Published on 2010-04-28T23:44:18Z Indexed on 2010/04/28 23:47 UTC
Read the original article Hit count: 294

Filed under:
|
|

I have an iPad application that uses the whole screen (that is, UIStatusBarHidden is set true in the Info.plist file). The main window's frame is set to (0, 0, 768, 1024), as is the main view in that frame. The main view has multitouch enabled.

The view has code to handle touches:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    for (UITouch *touch in touches) {
        CGPoint location = [touch locationInView:nil];
        NSLog(@"touchesMoved at location %@", NSStringFromCGPoint(location));
    }
}

When I run the app in the simulator, it works pretty much as expected. As I move the mouse from one edge of the screen to the other, reported X values go from 0 to 767. Reported Y values go from 20 to 1023, but it is a known issue that the simulator doesn't report touches in the top 20 pixels of the screen, even when there is no status bar.

Here's what's weird: When I run the app on an actual iPad, the X values go from 0 to 767 as expected, but reported Y values go from -6 to 1017.

The fact that it seems to work properly on the simulator leads me to suspect that real devices' touchscreens are not perfectly calibrated, and mine is simply reporting values six pixels too low. Can anyone verify that this is the case? Otherwise, is there anything else that could account for the Y values being six pixels off from what I expect?

(In a few days, I should have a second iPad, so I can test this with another device and compare the results.)

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ipad