2016-11-02 13 views
2

私は自分のアプリケーションでカメラオーバーレイビューを実装しました。カメラオーバーレイビューはiOS 9でうまくいきましたが、iOS 10 cameraViewTransformではこの問題を解決する方法がありません。私を案内してください。おかげUIImagePickerController cameraViewTransformがiOS 10で動作しません

私の作業コード

CGSize screenBounds = [UIScreen mainScreen].bounds.size; 
CGFloat cameraAspectRatio = 4.0f/3.0f; 
CGFloat camViewHeight = screenBounds.width * cameraAspectRatio; 
CGFloat scale = screenBounds.height/camViewHeight; 
picker.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight)/2.0); 
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, scale, scale); 

更新

OverlayView *overlay = [[OverlayView alloc] 
          initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; 
    picker = 
    [[UIImagePickerController alloc] init]; 
    picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
    picker.showsCameraControls = NO; 
    picker.navigationBarHidden = NO; 
    picker.toolbarHidden = YES; 

    // Device's screen size (ignoring rotation intentionally): 
    CGSize screenSize = [[UIScreen mainScreen] bounds].size; 

    float cameraAspectRatio = 4.0/3.0; 
    float imageWidth = floorf(screenSize.width * cameraAspectRatio); 
    float scale = ceilf((screenSize.height/imageWidth) * 10.0)/10.0; 





    picker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformIdentity, 2, 2); 
    picker.cameraOverlayView = overlay; 
    picker.allowsEditing = NO; 

    UIPinchGestureRecognizer *pinchRec = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(zoom:)]; 
    [overlay addGestureRecognizer:pinchRec]; 
    overlay.image =image; 
    [self.navigationController presentViewController:picker animated:NO completion:nil]; 

答えて

0

はこれを試してみてください:

私は以前にもIOS 9.3で同じ問題を抱えていました。ここに私が使用したコードがあります

//transform values for full screen support 
#define CAMERA_TRANSFORM_X 1 
#define CAMERA_TRANSFORM_Y 1.12412  

     if (IS_IPAD) 
      CGAffineTransformScale(objImagePickerController.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y); 
     else if (IS_IPHONE_5_Land||IS_IPHONE_4_Land||IS_IPHONE_6_Land||IS_IPHONE_6_PLUS_Land) 
     { 
      objImagePickerController.cameraViewTransform = CGAffineTransformScale(CGAffineTransformIdentity, 2, 2); 
     } 

希望します。詳細については、UIImagePickerController's cameraViewTransform is ignoring 'scaling' and 'translation' on iOS 10 beta

+0

ありがとうございます。@Jamshed Alam –

+0

okを確認して更新します。もう一度問題に直面すれば教えてください。 –

+0

あなたのコードを使用しましたが、まだ動作していません@ Jamshed Alam –

1

iOS 10.2がこの問題を修正しました。カメラを再び表示する前に、cameraViewTransformプロパティを使用できるようになりました。

関連する問題