2016-10-03 14 views
7

में पूर्णस्क्रीन में प्रदर्शित नहीं होता है, मैं फोटो कैप्चर करने के लिए इमेजपीकर ओवरले का उपयोग कर रहा हूं। आईओएस 9 में मेरा कोड ठीक काम करता है, लेकिन जब मैं आईओएस 10 पर अपना कोड चलाता हूं तो यह नीचे एक जगह दिखाता है जो आईओएस 9 पर प्रदर्शित नहीं होता है। मैंने इसे हल करने की कोशिश की लेकिन मैं इसे करने में सक्षम नहीं हूं।इमेजपिकर ओवरले केवल आईओएस 10

- (void)openCamerawithOption :(UIImagePickerControllerCameraCaptureMode)camType 
{ 
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
    { 

     [[NSOperationQueue mainQueue] addOperation:[NSBlockOperation blockOperationWithBlock:^{ 
      [self createImagePicker:camType]; 
     }]]; 
    } 
} 

-(void)createImagePicker :(UIImagePickerControllerCameraCaptureMode)camType 
{ 
    if (!imagePickerController) { 
     imagePickerController = [[NonRotatableImagePickerController alloc] init]; 
    } 
    //[imagePickerController.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height+(iOS7?0:20.0))]; 
    [APPSINGLETON setBorder:imagePickerController.view color:[UIColor redColor]]; 

    imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; 
    imagePickerController.delegate = self; 
    imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 
    imagePickerController.allowsEditing = YES; 
    imagePickerController.videoMaximumDuration = 60.0; 

    if (iOS7) { 
     CGSize screenBounds = APPDELEGATE.screenSize; 
     CGFloat cameraAspectRatio = 4.0f/3.0f; 
     CGFloat camViewHeight = screenBounds.width * cameraAspectRatio; 
     CGFloat scale = screenBounds.height/camViewHeight; 
     imagePickerController.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight)/2.0); 
     imagePickerController.cameraViewTransform = CGAffineTransformScale(imagePickerController.cameraViewTransform, scale, scale); 
    } else { 
     float cameraAspectRatio = 4.0/3.0; 
     float imageWidth = floorf(APPDELEGATE.screenSize.width * cameraAspectRatio); 
     float scale = ceilf(((APPDELEGATE.screenSize.height+20.0)/imageWidth) * 10.0)/10.0; 
     imagePickerController.cameraViewTransform = CGAffineTransformMakeScale(scale, scale); 
    } 

    imagePickerController.mediaTypes = [NSArray arrayWithObjects:(NSString)kUTTypeMovie, (NSString)kUTTypeImage, nil]; 
    imagePickerController.cameraCaptureMode = camType; 
    imagePickerController.showsCameraControls = NO; 
    imagePickerController.toolbar.hidden=YES; 
    imagePickerController.wantsFullScreenLayout = YES; 

    // not all devices have two cameras or a flash so just check here 
    if ([UIImagePickerController isCameraDeviceAvailable: UIImagePickerControllerCameraDeviceRear]) 
    { 
     imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear; 
    } 
    else 
    { 
     imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront; 
    } 

    if ([UIImagePickerController isFlashAvailableForCameraDevice:imagePickerController.cameraDevice]) 
    { 
     imagePickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto; 
    } 

    [self performSelectorOnMainThread:@selector(presentPicker) withObject:nil waitUntilDone:YES]; 
} 

-(void)presentPicker 
{ 
    [self presentViewController:imagePickerController animated:YES completion:nil]; 
    imagePickerController.cameraOverlayView = transparentView; 
} 

यहाँ स्क्रीनशॉट enter image description here

अद्यतन है::

self.presentViewController(
     self.imagePicker, 
     animated: true, 
     completion: { 
      let screenSize = UIScreen.mainScreen().bounds.size 
      let ratio: CGFloat = 4.0/3.0 
      let cameraHeight: CGFloat = screenSize.width * ratio 
      let scale: CGFloat = screenSize.height/cameraHeight 

      self.imagePicker.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenSize.height - cameraHeight)/2.0) 
      self.imagePicker.cameraViewTransform = CGAffineTransformScale(self.imagePicker.cameraViewTransform, scale, scale) 
     } 
    ) 

This solution from below is working for me except when I rotate the device the same issue returns. 

UIImagePickerController's cameraViewTransform is ignoring 'scaling' and 'translation' on iOS 10 beta

+0

लगता है कि यह आईओएस 10 बग है। इस बोर्ड को जांचें

+0

@AndrewVeresov आपका समाधान पहले लोड के लिए काम करता है लेकिन जब मैं स्क्रीन घुमाता हूं तो एक ही समस्या फिर से आती है क्या आप इस में मुझे मार्गदर्शन कर सकते हैं? –

उत्तर

1

@chirag शाह मैं नहीं मिला था महान समाधान ios10 में बदलना। मैंने बस अपने आईओएस 10 प्रोजेक्ट से इमेजपिकर छोड़ा और AVCaptureVideoGravviewLayer ऑब्जेक्ट के लिए वीडियो गुरुत्वाकर्षण AVLayerVideoGravityResizeAspectFill के साथ AVCaptureSession का उपयोग करें। यह पूरी तरह से काम है।

+0

पर काम नहीं कर रहा है मुझे बहुत सी चीज़ों को बदलने की ज़रूरत है, इसलिए मैं ImagePickerOverlay को AVLayerVideoGravityResizeAspectFill –

+0

में नहीं बदल सकता हूं आपकी टिप्पणी मेरे लिए काम कर रही है कि मैं आपका उत्तर –

0

यहाँ मेरी कोड कि इस मुद्दे को उत्पन्न करता हैआपकी वर्तमान पिकर विधि में पारदर्शी दृश्य क्या है? की स्थापना इस तरह यह फ्रेम है का प्रयास करें: imagePicker के लिए

transparentView.frame = imagePickerController.view.bounds; 
imagePickerController.cameraOverlayView = transparentView; 
[self presentViewController:imagePickerController animated:YES completion:nil]; 
+0

यह समाधान –

0

वास्तव में मुझे एक ही समस्या का सामना करना पड़ा। मैं एक उचित समाधान नहीं मिल सकता है के रूप में, मैं तो बस की तरह

CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, sizeMissingAtBottom); 
imagePickerController.cameraViewTransform = translate; 

तो CGAffineTransformScale आप अनुवाद कर सकते हैं यदि आवश्यक हो तो दृश्य की Ty बदल दिया।

+0

क्यों स्वीकार करता हूं मैंने आपके उत्तर की जांच की –