在iOS中禁用相机旋转?

在iOS中禁用相机旋转?,ios,camera,rotation,uiimagepickercontroller,autorotate,Ios,Camera,Rotation,Uiimagepickercontroller,Autorotate,添加UIImagePickerController的我的代码: picker = [[[UIImagePickerController alloc] init] autorelease]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.showsCameraControls = NO; [self displayContentC

添加UIImagePickerController的我的代码:

picker = [[[UIImagePickerController alloc] init] autorelease];
    picker.delegate = self;
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.showsCameraControls = NO;
    [self displayContentController:picker inView:cameraBoxView];
    [self.view sendSubviewToBack:picker.view];

- (void)displayContentController:(UIViewController *)content inView:(UIView *)v {

    //Delete the previous instance of the same view controller
    for (UIViewController *vc in self.childViewControllers) {

        if ([vc isKindOfClass:[content class]]) {

            [vc removeFromParentViewController];
        }
    }

    [self addChildViewController:content];
    content.view.frame = v.frame;
    [self.view addSubview:content.view];
    [content didMoveToParentViewController:self];

    if ([content isKindOfClass:[CCInnerNavigationController class]]) {

        innerNavigationController = (CCInnerNavigationController *)content;
    }
}
我已禁用除纵向外的所有设备方向。但是来自相机的图像是旋转的。如何在iOS 6和iOS 7中解决此问题


另外,我知道有很多解决方案,但它们似乎太旧了,因为它们都不起作用。

当您安装UIImagePickerController时,您还必须向其传递一名代表。代理应符合两个协议
UIImagePickerController远程门
UINavigationController远程门
。第二种方法可以在运行时为旋转添加一些逻辑,并根据您想要实现的实现这些方法

– navigationControllerPreferredInterfaceOrientationForPresentation:
– navigationControllerSupportedInterfaceOrientations:

我更改了以下代码:

imgView.image = img;
致:


现在它可以在iOS 6和iOS 7中使用。我不知道它是如何修复这个bug的,但它确实有效。图像选择器可能会损坏图像或图像视图,此代码通过创建新的图像实例来修复它。

NS\u AVAILABLE\u IOS(7\u 0);对双方来说。。。即使他们在iOS 7中工作,我也需要一个iOS 6 Toooopsss的解决方案。。。即使我不喜欢UIImagePikerController上的一个类别似乎是一个解决方案,他们的解决方案也不起作用:我仍然得到旋转的图像。似乎他们最好的答案应该是可行的,但我不知道如何正确地应用它。另外,我已尝试在所有应用程序中启用自动旋转。我看到picker的旋转是Always肖像,但结果是旋转的。这意味着如果设备是横向的,那么当我向上/向下移动设备时,预览图片会向左/向右移动。就我所读的内容而言,摄像头v.c.似乎只是纵向的,只是界面(和图像元数据)发生了变化
imgView.image = [UIImage imageWithCGImage:img.CGImage scale:1 orientation:UIImageOrientationRight];