IOS7 Xcode 5通用应用程序不会在iphone上旋转,但会在ipad上进行

时间:2014-03-07 18:30:31

标签: iphone ios7 xcode5

我有和应用程序最初是为ipad而构建的,我正在使它成为一个通用的应用程序。我已经让整个应用程序正常工作,通用,所有功能都正常工作和大小。除了在iPhone上,应用程序不会向任何方向旋转,它将保持纵向模式。

这就是我所拥有的:

  • 从目标/常规部分检查iPhone设备方向:(纵向,横向左侧和横向右侧)均已选中
  • 在我的Main_iPhone.storyboard中,我有一个根视图控制器连接到uinavigation控制器,在第一次加载应用程序时弹出设置(uitableview)。 (与ipad故事板相同,但尺寸适合iphone)
  • 视图控制器以编程方式将xib:TakePhotoView.xib加载到cameraOverlayView上,该视图上有标签,告诉用户触摸屏幕拍照。

同样,这在ipad上运行得很完美,而且我对ios开发很新。我实际上有一个朋友开发ipad应用程序和我;我用它作为我的步骤点挖掘ios,因此我试图把它变成一个通用的应用程序让我的脚湿。

任何指针都会非常感激。我正用这个把头发拉出来。

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

终于搞清楚了。这是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