2012-03-10 35 views
0

我正在做我的iPhone版本的應用程序,在應用程序中的iPhone專業版本只適用於視覺「肖像」版本,但它將是iPad景觀願景,看看我迄今爲止所做的:interfaceOrientation iPad

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 
} 
else{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

它檢測iPhone是否和它是否在任何位置都會處於橫向狀態,就是說iPad,iPhone Pro是相反的。

我沒有成功,沒有工作。

有人已經做了類似的事情?基本上我想要的很簡單,iPhone ==肖像,iPad ==風景;


我想在我的項目與在iPhone和iPad這兩個人像模式視圖實現,但仍一如既往地

我得到這個錯誤在調試:

視圖控制器從-shouldAutorotateToInterfaceOrientation返回NO:用於所有界面方向。它應該至少支持一種方向。

+0

我不...我的應用程序是一個無線電播放器,通過JP Floripa瀏覽應用商店,你可以看到我想要你的一個例子,iPhone ==肖像和iPad ==風景, 我做不知道他們是兩個單獨的應用還是通用的 我不知道他們是兩個單獨的應用還是通用的。 – jucajl 2012-03-10 13:56:53

+1

這不是事實。我有隻支持橫向導向的應用程序。關鍵是支持左右兩種風景模式。而這兩種方式的規則不適用於肖像模式。我有許多應用程序只支持常規的人像定位,但不能顛倒。 – erkanyildiz 2012-03-10 14:10:49

+0

但我的代碼呢?有沒有人有任何提示如何做? iPhone ==肖像,iPad == LandsCape – jucajl 2012-03-10 14:20:31

回答

0

試試看。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
     return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    } else { 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
    } 
} 

適合我!