я заставил свое приложение запускаться только в ландшафтном режиме, а не в портретном. На экране я открываю камеру для записи видео в UIView с использованием AVFoundation. Но его ориентация не меняется как ландшафт.. Идеи?
- (void) CameraSetOutputProperties
{
//SET THE CONNECTION PROPERTIES (output properties)
AVCaptureConnection *CaptureConnection = [MovieFileOutput connectionWithMediaType:AVMediaTypeVideo];
//Set landscape (if required)
if ([CaptureConnection isVideoOrientationSupported])
{
AVCaptureVideoOrientation orientation = AVCaptureVideoOrientationLandscapeRight; //<<<<<SET VIDEO ORIENTATION IF LANDSCAPE
[CaptureConnection setVideoOrientation:orientation];
}
}
//
- (void)initializeCamera {
captureSession = [[AVCaptureSession alloc]init];
captureSession.sessionPreset = AVCaptureSessionPresetHigh;
_previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:captureSession];
[_previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
....
if (!frontCamera) {
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:backCamera error:&error];
if (!input) {
NSLog(@"ERROR: trying to open camera: %@", error);
}
[captureSession addInput:input];
}
if (frontCamera) {
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:frontCamera error:&error];
if (!input) {
NSLog(@"ERROR: trying to open camera: %@", error);
}
[captureSession addInput:input];
}
[captureSession startRunning];