2011-11-09 34 views
0

希望有人能在這裏指出我在我的Splash屏幕上做錯了什麼。問題是,在屏幕處於縱向模式,而不是景觀提前顯示...爲什麼我的ModalView以縱向模式顯示?

- (void)showSplash 
{  
UIView *modelView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024 , 748)]; 

UIViewController *modalViewController = [[UIViewController alloc] init]; 
[modelView setBackgroundColor:[[UIColor alloc] initWithPatternImage:[UIImage  imageNamed:@"Splash.png"]]]; 

modalViewController.view = modelView; 

[self presentModalViewController:modalViewController animated:NO]; 


[self performSelector:@selector(hideSplash) withObject:nil afterDelay:5.0]; 

}的幫助

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

感謝。

+1

通過啓動屏幕顯示http://stackoverflow.com/questions/3772016/modal-view-controller-wont-start-in-landscape-mode –

+0

您的意思是應用程序啓動時顯示的默認圖像是否正確? – slonkar

+0

是應用程序啓動時加載的一個... – Nathan

回答

1

看起來您正在爲iPad編寫應用程序。如果是這樣,你必須同時支持橫向和縱向定向,否則蘋果會拒絕它。我建議你應該使用兩個不同的圖像。圖片規格如下:

  1. 默認-Landscape.png(1004 * 768)
  2. 默認-Portrait.png(748 * 1024)

(我假設你是顯示狀態如果不添加20像素高度的圖像)

就是這樣,創建這些圖像並將其添加到您的項目。你很好走。不需要寫任何額外的代碼太..

雅使其

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return YES; 
} 
+0

其實這個應用程序只支持橫向,根據蘋果建議您支持所有,但他們不需要它.. http://developer.apple.com/庫/ IOS /#QA/qa1689/_index.html – Nathan

0

你不應該依賴於你的代碼來顯示啓動畫面的功能。只需將它們定義爲Sumit Lonkar先前解答的答案即可。

如果在代碼中執行此操作,我相信在應用程序的開始時方向總是被視爲縱向,然後觸發到實際方向的轉​​換。這就解釋了爲什麼你的代碼首先顯示爲肖像,而且很可能代碼中沒有其他內容可以處理旋轉。此外,啓動畫面的目的是在應用程序加載時顯示某些內容,因此如果將其放入代碼中,您將失去目的。

通過這樣做蘋果的方式,你把它留給另一個蘋果的過程,運行之前看你的代碼,它會工作。

關於支持的方向,我在我的iPad上有一些僅支持橫向的應用程序(例如TapZoo),因此它應該可以與Apple一起使用。

相關問題