2010-03-09 59 views
0

我正在尝试使此横向仅限 iphone应用。iPhone横向模式中的触摸坐标应用

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

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

然而,当我点击从Interface Builder的剪辑子视图复选框,将画面从中间截断。

我也没有收到任何来自视界外界的触摸事件。

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

只打印坐标在20和320之间的X.但Y工作正常。

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

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

什么可能导致这种情况?奇怪的!

+0

现在,我用这个: self.view.frame = CGRectMake(0.0f,0.0f,480.0f,320.0f); 更逻辑的代码:)但仍然,我没有得到0和20之间的任何接触X. – gok 2010-03-09 11:15:06

+0

好吧,我认为它被状态栏阻止。但是状态栏是隐藏的。如何克服这一点? – gok 2010-03-09 11:22:02

+0

found found:http://www.iphonedevsdk.com/forum/iphone-sdk-development/1663-disabling-top-status-bar-application.html 在plist文件中UIStatusBarHidden = true,但仍然没有运气。哈哈在这里疯狂:) – gok 2010-03-09 11:34:30

回答

0

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