触摸iPhone横向模式应用中的坐标

时间:2010-03-09 10:04:30

标签: iphone

我正在努力制作仅景观 iphone app。

我只将此代码用于此目的:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); }

但是,当我从界面构建器中单击剪辑子视图复选框时,视图将从中间剪切。

我也没有从视界之外收到任何触摸事件。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint fingerPos = [[touches anyObject] locationInView:self.view];
NSLog(@"%f   %f",fingerPos.x,fingerPos.y); }

仅为X打印20到320之间的坐标。但Y工作正常。

当我尝试手动修改边界时,一切正常;视图定位和显示正确,打印坐标正确,我接收来自所有屏幕的触摸,除了0到20之间的X.因此屏幕的左侧对触摸事件没有响应仅20像素。我用来修改边界的代码:

self.view.bounds = CGRectMake(-180.0f, 0.0f, 680.0f, 480.0f);

可能导致这种情况的原因是什么?怪异!

1 个答案:

答案 0 :(得分:0)

好的,正如我在评论中发布的链接所说,触摸事件在设备上正确接收。所以这是模拟器的问题。