簡體   English   中英

方向不支持ios6設備

[英]orientation not supporting in ios6 devices

我有一個基於xcode 4.2的應用程序,它只支持縱向方向,它適用於除ios6之外的所有設備..在Ios 6設備中它顯示兩個方向..我只需要縱向...我正在使用導航控制器.. IN appdelegate ::

- (BOOL)shouldAutorotate
{

      return ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait);
}


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

在其他viewControllers ::

- (BOOL)shouldAutorotate {
    return YES;
}

- (void)viewDidLayoutSubviews
{
    DisplayFunctionName;
    NSLog(@"orientation: %d",self.interfaceOrientation);
}

- (NSUInteger)supportedInterfaceOrientations
{
    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
    {
        return (UIInterfaceOrientationMaskAll);
    }
    else
    {
        return (UIInterfaceOrientationMaskPortrait);
    }
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    DisplayFunctionName;
    NSLog(@"orientation: %d",interfaceOrientation);
      return (interfaceOrientation==UIInterfaceOrientationPortrait);

}

在IOS6中,當您想要某些視圖的縱向方向以及某些您想要橫向方向時,處理方向很困難,但如果您只想為整個應用程序提供一個方向支持,則非常容易。 簡單轉到支持文件 ,然后在您的應用程序中打開info.plist並刪除除您想要的所有其他方向..下面是幾個屏幕截圖,可以幫助您解決問題

在此輸入圖像描述

在此輸入圖像描述

刪除所有其他方向后,您的info.plist將如下所示 在此輸入圖像描述

我希望它適合你。謝謝

iOS 6

shouldAutorotateToInterfaceOrientation :已棄用並替換為

shouldAutorotate

請查看: https//stackoverflow.com/a/14938444/305135

嘗試使用這些,

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

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

暫無
暫無

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

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