簡體   English   中英

定向支持

[英]Orientations support

我有一個帶有某些視圖的應用程序,我需要一個視圖才能旋轉。 該視圖由pushviewcontroller調用。 所有這些視圖都在tabbarcontroller中。

我已經編輯了info.plist來支持方向。我已經將此項目添加到了受支持的界面方向:橫向(左側主頁按鈕)橫向(右側主頁按鈕)

並將其添加到我要旋轉的視圖中

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

但它不起作用。

我需要做什么? 謝謝

UITabBarController有一些問題。 問題是一個子視圖(選定的索引)不能自動旋轉。

因此,您可以創建一個類別,並添加以下代碼。

並添加一個#import“ UITabBarController + Autorotate.h”

#import <Foundation/Foundation.h>


@interface UITabBarController (Autorotate)

@end

#import "UITabBarController+Autorotate.h"


@implementation UITabBarController (Autorotate)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    UIViewController *controller = self.selectedViewController;
    if ([controller isKindOfClass:[UINavigationController class]])
        controller = [(UINavigationController *)controller visibleViewController];
    return [controller shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

@end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM