2014-09-17 2 views

ответ

5

вы должны ждать AVCaptureInputPortFormatDescriptionDidChangeNotification

- (void)avCaptureInputPortFormatDescriptionDidChangeNotification:(NSNotification *)notification { 

    AVCaptureInput *input = [self.recorder.captureSession.inputs objectAtIndex:0]; 
    AVCaptureInputPort *port = [input.ports objectAtIndex:0]; 
    CMFormatDescriptionRef formatDescription = port.formatDescription; 
    if (formatDescription) { 
     CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription); 
     if ((dimensions.width == 0) || (dimensions.height == 0)) { 
      return; 
     } 
     CGFloat aspect = (CGFloat)dimensions.width/(CGFloat)dimensions.height; 

     if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) { 
      // since iOS8 the aspect ratio is inverted 
      // remove this check if iOS7 will not be supported 
      aspect = 1.f/aspect; 
     } 

    } 

} 
+0

Не могли бы вы просто проверить свойство 'activeFormat' на текущем устройстве? https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVCaptureDevice_Class/index.html#//apple_ref/occ/instp/AVCaptureDevice/activeFormat – Crashalot

Смежные вопросы