簡體   English   中英

IOS7 Xcode 5通用應用程序不會在iPhone上旋轉,但會在iPad上旋轉

[英]IOS7 Xcode 5 universal app won't rotate on iphone, but will on ipad

我擁有一個最初為ipad打造的應用程序,並且我正在使其成為通用應用程序。 總的來說,我已經使整個應用程序正常工作,所有功能都在正常工作並且大小正確。 除了在iPhone上,該應用不會向任何方向旋轉外,它始終處於縱向模式。

這是我所擁有的:

  • 從“目標/常規”部分檢查了“ iPhone設備方向” :(縱向,左橫向和右橫向)都已選中
  • 在我的Main_iPhone.storyboard中,我有一個連接到uinavigation控制器的根視圖控制器,該控制器會在應用程序首次加載時彈出設置(uitableview)。 (與ipad故事板相同,但大小適合iphone)
  • 視圖控制器以編程方式將xib:TakePhotoView.xib加載到cameraOverlayView上,該相機上有一個標簽,告訴用戶觸摸屏幕進行拍照。

再次,這在ipad上非常完美,我對ios開發還是很陌生。 我實際上有一個朋友開發了ipad應用程序,我將其用作深入研究ios的出發點,因此,我試圖將其轉變為通用應用程序,以使我的腳浸濕。

任何指針將不勝感激。 我正在用這個拔頭發。

 (BOOL) shouldAutorotate{
    return YES;
}
- (NSUInteger) supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeRight; //you can choose either landscape orientation here
}

終於弄明白了。 它是UIImagePickerController。 由於某種原因,它對於ipad來說非常完美,但是我需要為iphone覆蓋它。

#import "UIImagePickerController+rotation.h"

@interface UIImagePickerController (private)

- (BOOL)shouldAutorotate;
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
- (NSUInteger)supportedInterfaceOrientations;
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;

@end


@implementation UIImagePickerController (Private)

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskAll;
}

- (BOOL)shouldAutorotate {

    return UIInterfaceOrientationMaskAll;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        return UIInterfaceOrientationPortrait;
    }
    else
    {
        return UIInterfaceOrientationLandscapeRight;
    }
}

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

暫無
暫無

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

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