ios - 相机预览不填满屏幕
<p><p>这就是我在 iPad3 中以横向模式设置相机预览的方式</p>
<pre><code>- (void)viewDidAppear:(BOOL)animated
</code></pre>
<p>{</p>
<pre><code>AVCaptureSession *session = [ init];
session.sessionPreset = AVCaptureSessionPreset640x480;
CALayer *viewLayer = self.vImagePreview.layer;
NSLog(@"viewLayer = %@", viewLayer);
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [ initWithSession:session];
captureVideoPreviewLayer.frame = self.vImagePreview.bounds;
;
AVCaptureDevice *device = ;
NSError *error = nil;
AVCaptureDeviceInput *input = ;
if (!input) {
// Handle the error appropriately.
NSLog(@"ERROR: trying to open camera: %@", error);
}
;
stillImageOutput = [ init];
NSDictionary *outputSettings = [ initWithObjectsAndKeys: AVVideoCodecJPEG, AVVideoCodecKey, nil];
;
;
;
</code></pre>
<p>}</p>
<p>在 Storyboard 中,我将 View 设置为填满整个屏幕,但它最终看起来像这样:</p>
<p> <img src="/image/bcohw.png" alt="enter image description here"/> </p>
<p>此外,图像也旋转了 90 度。如何更改此设置,以便让相机预览充满整个屏幕?</p>
<p>谢谢。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>旋转图层:</p>
<pre><code> switch (self.interfaceOrientation)
{
case UIInterfaceOrientationLandscapeRight:
;
break;
case UIInterfaceOrientationLandscapeLeft:
;
break;
}
;
</code></pre></p>
<p style="font-size: 20px;">关于ios - 相机预览不填满屏幕,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/12706851/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/12706851/
</a>
</p>
页:
[1]