當前正在創建iPad應用程序,它在登錄屏幕後顯示Tabbar。到目前爲止,能夠成功顯示tabbar及其相關視圖,唯一的問題是我的tabbar沒有出現在橫向模式下。UITabbar僅適用於橫向
我只希望我的應用程序只在橫向。
請教我如何旋轉縱向標籤欄到橫向標籤欄。
當前正在創建iPad應用程序,它在登錄屏幕後顯示Tabbar。到目前爲止,能夠成功顯示tabbar及其相關視圖,唯一的問題是我的tabbar沒有出現在橫向模式下。UITabbar僅適用於橫向
我只希望我的應用程序只在橫向。
請教我如何旋轉縱向標籤欄到橫向標籤欄。
使用這種方法在你的所有文件viewControlle.m
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
除了實現shouldAutorotateToInterfaceOrientation:在所有相關的視圖控制器,請確保您的myProjectName-Info.plist文件指定您選擇支持的接口方向:
您也可以通過選擇在Project Navigator的項目(查看>導航器>顯示項目瀏覽器)設置此,選擇目標,並然後摘要選項卡,然後按所需方向按鈕:
:它僅適用於所有方向? – 2012-02-23 05:32:18
@MuditBajpai不,只選擇你需要的方向。 – MattyG 2012-02-23 06:18:04
你是否檢查過所有方向?我檢查過。只有這樣纔是不夠的,你必須執行我已經回答的方法。 – 2012-02-23 07:01:59
試試這個代碼: - 對於(在UITabBar旋轉一個UIViewController中)在viewWillAppear中,並使用CGAffineTransform
- (void)viewWillAppear:(BOOL)animated; {
//-- Adjust the status bar
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
//-- Rotate the view
CGAffineTransform toLandscape = CGAffineTransformMakeRotation(degreesToRadian(90));
toLandscape = CGAffineTransformTranslate(toLandscape, +90.0, +90.0);
[self.view setTransform:toLandscape];
}
變化中的所有項目: - 複製並粘貼所有ViewController
1)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
2) Change in Info.Plist
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>
是的,在我所有的視圖控制器中完成。但仍然處於風景模式 – JiteshW 2012-02-23 05:04:33