簡體   English   中英

如何在IOS6中旋轉單個視圖控制器

[英]How to rotate a single View Controller in IOS6

如何在ios6旋轉iPad中的單個ViewController 我已經使用過代表了

appdelegate.m

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}

它使所有的viewcontroller肖像和我只想在橫向模式之間的單個viewcontroller

在graphViewController.m中

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

但我無法得到正確的結果,請盡快回復。 謝謝。

請參閱此鏈接iOS6發行說明

在UIKit下 - >自動旋轉在iOS 6中正在發生變化

“更多的責任轉移到應用程序和應用程序委托。現在,iOS容器(如UINavigationController)不會咨詢他們的孩子,以確定他們是否應該自動旋轉。”

在任何UIViewController中都不會調用shouldAutorotate(在iOS6中),它位於另一個控制器(例如UINavigationController)中。

您應該使用UINavigationController的shouldAutorotate方法(如果您使用它)來確定顯示哪個子項並強制給定方向

在viewController中使用此方法,而不是在app delegate.m中旋轉

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

因為在下面的方法中你正在旋轉窗口,這就是為什么它改變整個應用程序。

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}

暫無
暫無

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

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