【发布时间】:2012-11-04 19:26:00
【问题描述】:
我在 iOS 中发现了有趣的错误,但我试图相信我错了。你必须做两件事:
1) 为 iOS 创建单视图模板
2) 在 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] 范围内的点...我无法解释这一点,它只发生在设备上,在模拟器中可以正常工作。
一些调试信息:
带状态栏和 NO WantedFullScreenLayout 范围是:[-25.5 .. 449]
带状态栏和YES WantsFullScreenLayout 范围是:[-5.5 .. 469]
没有状态栏和 NO/YES FullScreenLayout 范围是:[-5.5 .. 469]
带状态栏和 NO WantsFullScreenLayout view.frame 是 (0, 20, 320, 460) 并且 view.bounds 是 (0, 0, 320, 460)
带有状态栏和YES WantsFullScreenLayout view.frame 是 (0, 0, 320, 480) 并且 view.bounds 是 (0, 0, 320, 480)
没有状态栏和 NO/YES FullScreenLayout view.frame 是 (0, 0, 320, 480) 并且 view.bounds 也是 (0, 0, 320, 480)
请帮忙解释一下这些东西,它只发生在设备上...
【问题讨论】:
-
你考虑到状态栏了吗?尝试在您的视图控制器上设置
wantsFullScreenLayout并再次测试。 -
带状态栏并且没有想要FullScreenLayout 范围是:[-25.5 .. 449]
-
带状态栏和YES WantsFullScreenLayout 范围是:[-5.5 .. 469]
-
没有状态栏和 NO/YES FullScreenLayout 范围是:[-5.5 .. 469]
-
这很奇怪。请添加
NSLog(@"%@", NSStringFromCGPoint(self.view));并发布输出
标签: iphone objective-c ios cocoa-touch uikit