我将info.plist里面可旋转的方向给成3个。
然后再ViewController里面添加了这个方法。相册可以进去了。而且View也一直保持home键在左的方向。
-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}
但是我进入拍照功能的时候。快门键永远在右边。而且拍照界面会跟着机器旋转而旋转。只有home键在左边的时候界面内容才是正确方向。比如把机器home键放到底部的时候。快门键还是在右边。home键放到右边的时候,快门虽然在右。可是镜像旋转了180度。
我想把界面控制在home键在左边。快门在右。机器旋转的时候界面不变。这要怎么实现?

解决方案 »

  1.   

    如果系统对此进行了限制,那么就通过ALAssetLibrary来自己实现一个PickerController
      

  2.   

    我相册是可以横屏的。但是相机的界面会旋转。能不能固定相机出来的第一个方向?
    可以,相机的页面应该在一个NavigationController里,你写一个NavgationController的类别,在里面重写shouldAutorotate、supportedInterfaceOrientations、preferredInterfaceOrientationForPresentation这三个方法
      

  3.   

    我相册是可以横屏的。但是相机的界面会旋转。能不能固定相机出来的第一个方向?
    可以,相机的页面应该在一个NavigationController里,你写一个NavgationController的类别,在里面重写shouldAutorotate、supportedInterfaceOrientations、preferredInterfaceOrientationForPresentation这三个方法
    我已经自定义一个裁剪页了。还可以重写这三个方法么。。
      

  4.   

    我相册是可以横屏的。但是相机的界面会旋转。能不能固定相机出来的第一个方向?
    可以,相机的页面应该在一个NavigationController里,你写一个NavgationController的类别,在里面重写shouldAutorotate、supportedInterfaceOrientations、preferredInterfaceOrientationForPresentation这三个方法
    我已经自定义一个裁剪页了。还可以重写这三个方法么。。
    需要的,如果NavigationController支持多个方向也是不行的,总而言之,是需要写在最外层的Controller里,你可以类似于这样:- (BOOL)shouldAutorotate {
        return [[self.viewControllers lastObject] shouldAutorotate];
    }- (NSUInteger)supportedInterfaceOrientations {
        return [[self.viewControllers lastObject] supportedInterfaceOrientations];
    }- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
    }然后交由你自己的VC去处理
      

  5.   

    我相册是可以横屏的。但是相机的界面会旋转。能不能固定相机出来的第一个方向?
    可以,相机的页面应该在一个NavigationController里,你写一个NavgationController的类别,在里面重写shouldAutorotate、supportedInterfaceOrientations、preferredInterfaceOrientationForPresentation这三个方法
    我已经自定义一个裁剪页了。还可以重写这三个方法么。。
    需要的,如果NavigationController支持多个方向也是不行的,总而言之,是需要写在最外层的Controller里,你可以类似于这样:- (BOOL)shouldAutorotate {
        return [[self.viewControllers lastObject] shouldAutorotate];
    }- (NSUInteger)supportedInterfaceOrientations {
        return [[self.viewControllers lastObject] supportedInterfaceOrientations];
    }- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
    }然后交由你自己的VC去处理
    我写到我的VC里面之后全部报错了。
      

  6.   

    我相册是可以横屏的。但是相机的界面会旋转。能不能固定相机出来的第一个方向?
    可以,相机的页面应该在一个NavigationController里,你写一个NavgationController的类别,在里面重写shouldAutorotate、supportedInterfaceOrientations、preferredInterfaceOrientationForPresentation这三个方法
    我已经自定义一个裁剪页了。还可以重写这三个方法么。。
    需要的,如果NavigationController支持多个方向也是不行的,总而言之,是需要写在最外层的Controller里,你可以类似于这样:- (BOOL)shouldAutorotate {
        return [[self.viewControllers lastObject] shouldAutorotate];
    }- (NSUInteger)supportedInterfaceOrientations {
        return [[self.viewControllers lastObject] supportedInterfaceOrientations];
    }- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
    }然后交由你自己的VC去处理
    最开始的时候就是加了这一句
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscapeLeft;
    }
    才能够固定我之前的View方向。
    否则是可以旋转的。
      

  7.   

    我相册是可以横屏的。但是相机的界面会旋转。能不能固定相机出来的第一个方向?
    可以,相机的页面应该在一个NavigationController里,你写一个NavgationController的类别,在里面重写shouldAutorotate、supportedInterfaceOrientations、preferredInterfaceOrientationForPresentation这三个方法
    我已经自定义一个裁剪页了。还可以重写这三个方法么。。
    需要的,如果NavigationController支持多个方向也是不行的,总而言之,是需要写在最外层的Controller里,你可以类似于这样:- (BOOL)shouldAutorotate {
        return [[self.viewControllers lastObject] shouldAutorotate];
    }- (NSUInteger)supportedInterfaceOrientations {
        return [[self.viewControllers lastObject] supportedInterfaceOrientations];
    }- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
    }然后交由你自己的VC去处理
    最开始的时候就是加了这一句
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscapeLeft;
    }
    才能够固定我之前的View方向。
    否则是可以旋转的。

    恩,但是系统相机的页面可没有这么写,你把那三个方法写在UINavigation的类别里,可以先把这个类别放在AppDelegate里测试一下
      

  8.   

    我相册是可以横屏的。但是相机的界面会旋转。能不能固定相机出来的第一个方向?
    可以,相机的页面应该在一个NavigationController里,你写一个NavgationController的类别,在里面重写shouldAutorotate、supportedInterfaceOrientations、preferredInterfaceOrientationForPresentation这三个方法
    我已经自定义一个裁剪页了。还可以重写这三个方法么。。
    需要的,如果NavigationController支持多个方向也是不行的,总而言之,是需要写在最外层的Controller里,你可以类似于这样:- (BOOL)shouldAutorotate {
        return [[self.viewControllers lastObject] shouldAutorotate];
    }- (NSUInteger)supportedInterfaceOrientations {
        return [[self.viewControllers lastObject] supportedInterfaceOrientations];
    }- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
    }然后交由你自己的VC去处理
    最开始的时候就是加了这一句
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscapeLeft;
    }
    才能够固定我之前的View方向。
    否则是可以旋转的。

    恩,但是系统相机的页面可没有这么写,你把那三个方法写在UINavigation的类别里,可以先把这个类别放在AppDelegate里测试一下
    我没有用UINavigation这个来跳转。我现在开了一个新的控制器。然后需要拍照的时候再跳到拍照的视图控制器去。可是它根本就不出来。。还有警告。。还有刚刚加了一个第三方包。也报错了。。
      

  9.   

    我之所以提到 NavigationController,是因为UIImagePickerController好像就是继承自NavigationController了的,你试下写一个UIImagePickerController的子类 
      

  10.   

    谢谢大大。我把这个问题弄复杂了。我发现我写的调用相机的方法写出来后。在iPad上面就会旋转。代码我都贴出来在新的问题里面了。谢谢你。