iPad / iPhone触控点因校准错误吗? [英] Can iPad/iPhone Touch Points be Wrong Due to Calibration?

查看:161
本文介绍了iPad / iPhone触控点因校准错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用整个屏幕的iPad应用程序(即 UIStatusBarHidden 在Info.plist文件中设置为true)。主窗口和主视图的帧设置为(0,0,768,1024)。主视图启用了多点触控。

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));
    }
}

当我在模拟器中运行应用程序时,它可以工作几乎和预期的一样。当我将鼠标从屏幕的一个边缘移动到另一个边缘时,报告的X值从0到767.报告的Y值从20到1023.(这是一个已知问题模拟器未报告顶部的触摸屏幕的20个像素,即使没有状态栏。)

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.)

这是奇怪的事情:当我在实际的iPad上运行应用程序时,X值按预期从0到767,但报告的Y值从-6到1017,而不是0到1023,正如我所料。

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.

事实是它似乎在模拟器上正常工作让我怀疑真实设备的触摸屏没有完美校准,我的只是报告六个像素关闭的Y值。任何人都可以验证是这种情况吗?否则,是否有其他任何因素可以解释Y值与我的预期相差六个像素?

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?

(几天后,我应该有第二个iPad,所以我可以用另一台设备测试这个并比较结果。)

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

推荐答案

做一些快速测试我注意到了同样的事情。我开始了一个基于视图的基本项目,但没有改变,但代码如下:

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

(iPadTestsAppDelegate)

(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)

(iPadTestsViewController)

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

当我触摸屏幕边缘时报告为负x轴上的数字,y轴上的数字永远不会达到0。添加一些变量以跟踪最大值和最小值可以将这些作为我们iPad的角落:{-5,2},{758,2},{ - 5,1019},{758,1019}。

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}.

这篇关于iPad / iPhone触控点因校准错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆