2010-11-15 55 views
0

嗨全部 我正在實現一個使用TabBar和導航控制器的應用程序。在這個應用程序中,我需要更改特定視圖的方向(我的應用程序中的照片庫視圖)(想要實現方向功能)。我在所有視圖控制器的shouldautoroateorientation中設置了布爾值YES。通過這樣做,所有的視圖都是旋轉的。我只想旋轉一個特定的視圖。任何人都有關於它的想法請回復。Iphone中的方向問題

在此先感謝.... :)

回答

1

唯一的意見應該返回「YES」爲shouldAutoRotateOrientation是那些真正想旋轉。請注意,這意味着,有時導航和標籤欄控制器將返回YES,有時它們應返回NO。

我還沒有真正嘗試過這一點,但設置它,看看會發生什麼......

+0

我已經這樣做了,但它沒有工作... – 2010-11-16 07:06:10

+0

它適合我。看到我的新答案。 – 2010-11-21 07:07:48

0

你評估在shouldAutorotateOrientation的方向是什麼?如果你的目標手機,您的實現應該是這樣的觀點,即要允許對

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

旋轉,這在所有其他視圖

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
+0

嗨朋友感謝您的寶貴建議......我在這裏得到了解決方案 – 2010-11-19 04:17:38

+0

請點擊此鏈接並轉到此文件的第42頁... It Works For Me ... http://docs.huihoo .com/apple/iphone/iphone-application-programming/06-ViewControllers.pdf – 2010-11-19 04:18:21

+0

請忽略以前的解決方案並點擊此鏈接http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ViewControllerPGforiPhoneOS.pdf – 2010-11-19 04:20:38

1

我開始一個新的標籤欄應用程序,然後創建一個「MyTabBarController」類(從UITabBarController派生),並將MainWindow.xib更改爲使用MyTabBarController而不是UITabBarController。然後,我添加以下代碼MyTabBarController:

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation 
{ 
    BOOL result = interfaceOrientation == UIInterfaceOrientationPortrait; 
    if (self.selectedIndex == 0) 
     result = YES; 
    return result; 
} 

一旦我做到了,只有第一個視圖控制器會轉動,第二個不會。

但是,我注意到,只有當設備實際旋轉時,纔會調用此方法,一旦在橫向上,在另一個選項卡上輕敲會將橫向調整。所以也許你想做的事情不能完全做到。