Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 and main view's frames are set to (0, 0, 768, 1024). The main view has multitouch enabled.

The view controller has this 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. (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, not 0 to 1023 as I would expect.

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 Y values that are six pixels off. 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.)

like image 891
Kristopher Johnson Avatar asked Apr 28 '10 23:04

Kristopher Johnson


2 Answers

Doing some quick testing I noticed the same thing. I started a basic view based project with nothing changed but the following code:

(iPadTestsAppDelegate)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];

    // Override point for customization after app launch    
    viewController.view.multipleTouchEnabled = YES;
    viewController.view.userInteractionEnabled = YES;

    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

    return YES;
}

(iPadTestsViewController)

- (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 touch the edges of the screen it reports negative numbers on the x-axis and never hits 0 on the y-axis. Adding some variables to keep track of max and min gives me these as the corners of our iPad: {-5, 2}, {758, 2}, {-5, 1019}, {758, 1019}.

like image 175
MrHen Avatar answered Sep 30 '22 18:09

MrHen


I'm getting different values for different UIInterfaceOrientations

UIInterfaceOrientation ori = [UIApplication sharedApplication].statusBarOrientation;
CGPoint point = [touch locationInView:self];

Given that, I'd assume this is a software issue, not a device issue.

like image 44
Sylem Avatar answered Sep 30 '22 19:09

Sylem