Camera view(UIImagePickerController)显示不同ios设备的不同方向

时间:2016-08-08 11:12:04

标签: ios objective-c cocos2d-iphone uiimagepickercontroller

我正在cocos2d-iphone工作并尝试制作增强现实游戏。首先我跟着this tutorial但我遇到了问题。

我的示例代码是:

#product.h

@interface Product : CCNode <UIImagePickerControllerDelegate,UINavigationControllerDelegate>
{
    UIView *overlay;
    UIImagePickerController *cameraUI;
}

+(CCScene *) scene;
-(void)loadCameraView;

@end

然后

product.m

#define CAMERA_TRANSFORM  1.24299
-(void)loadCameraView
{
    // prepare the overlay view and add it to the window
    overlay = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    overlay.opaque = NO;
    overlay.backgroundColor=[UIColor clearColor];

    cameraUI = [[UIImagePickerController alloc] init];
    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
    cameraUI.showsCameraControls = NO;
    cameraUI.toolbarHidden = YES;
    cameraUI.navigationBarHidden = YES;
    cameraUI.wantsFullScreenLayout = YES;
    //cameraUI.shouldAutorotate = NO;
    cameraUI.cameraViewTransform = CGAffineTransformScale(cameraUI.cameraViewTransform,
                                                          CAMERA_TRANSFORM, CAMERA_TRANSFORM);

    [overlay addSubview:[cameraUI view]];

    //[[CCDirector sharedDirector].view addSubview:overlay];
    [appDelegate.window addSubview:overlay];

    [CCDirector sharedDirector].view.backgroundColor = [UIColor clearColor];
    [CCDirector sharedDirector].view.opaque = NO;

    //[appDelegate.navController.view setUserInteractionEnabled:false];
    [appDelegate.window bringSubviewToFront:appDelegate.navController.view];

}

此代码工作正常并加载相机。但是在诸如iPhone, iPad, iPod和不同ios version like: 7.0+, 8.0+, 9.0+的各种设备中,相机视图不会在所有设备中显示相同的视图,图像在所有设备的相同方向上旋转 - / + 90度或更多

那么,我可以为这个问题做些什么来获得相同的观点呢?

由于

0 个答案:

没有答案