TouchMoved和错误的屏幕范围?或在iOS中的错误? [英] TouchMoved and wrong screen range? or Bug in iOS?

查看:122
本文介绍了TouchMoved和错误的屏幕范围?或在iOS中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS中发现了有趣的错误,但试图相信我错了。你必须做两件事:

I found interesting bug in iOS, but trying to belive that i'm wrong. You have to do 2 things:

1)为iOS创建单视图模板

1) Create single-view template for iOS

2)函数在ViewController.m中:

2) Write small function in ViewController.m :

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{
    UITouch* touch = [touches anyObject];
    CGPoint point = [touch locationInView:[touch view]];
    NSLog(@"%@", NSStringFromCGPoint(point));
}// so u can detect points of your touch

手指显示从屏幕的顶部到底部(肖像模式) - 你得到的范围内的点 [ - 5.5 .. 469] ...我不能解释这一点,它只发生在设备上,在模拟器它工作正常。

So if u try to move finger on display from screen's top to bottom (portrait mode) - you get points in range [-5.5 .. 469]... i can't explain this, it happens only on device, in simulator it works fine.

一些调试信息:

wantsFullScreenLayout范围是:[-25.5 ... 449]

with status bar and NO wantsFullScreenLayout range is: [-25.5 .. 449]

带状态栏和YES wantsFullScreenLayout范围是:[-5.5 ... 469]

with status bar and YES wantsFullScreenLayout range is: [-5.5 .. 469]

没有状态栏和NO / YES FullScreenLayout的范围是:[-5.5..469]

without status bar and NO/YES FullScreenLayout the range is: [-5.5 .. 469]

有状态栏,而NO wantsFullScreenLayout view.frame是(0,20,320,460)和view.bounds是(0,0,320,460)。

with status bar and NO wantsFullScreenLayout view.frame is (0, 20, 320, 460) and view.bounds is (0, 0, 320, 460)

状态栏和YES wantsFullScreenLayout view.frame是(0,0,320,480)和view.bounds是(0,0,320,480)

with status bar and YES wantsFullScreenLayout view.frame is (0, 0, 320, 480) and view.bounds is (0, 0, 320, 480)

bar和NO / YES FullScreenLayout view.frame是(0,0,320,480),view.bounds也是(0,0,320,480)。

without status bar and NO/YES FullScreenLayout view.frame is (0, 0, 320, 480) and view.bounds is too (0, 0, 320, 480)

请帮助解释这个东西,它只会发生在设备上...

Please, help to explain this stuff, it happens only on devices...

推荐答案

根viewController的视图总是像纵向模式。您应该在根目录中插入一个新视图。

The view of root viewController always acts like portrait mode. You should insert a new view inside of the root one. And this new view will acts correctly, will give right size and coordinates according to Apple says.

例如:

UIView *v = self;
while ([[v superview] superview] != NULL) {
    v = [v superview];
}

UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:v];

touchPoint将是正确的。

touchPoint will be the correct one.

这篇关于TouchMoved和错误的屏幕范围?或在iOS中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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