2010-03-09 63 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

好的,正如我在評論中發佈的鏈接中所說,觸摸設備上正確接收的事件。所以這是一個模擬器的問題。