Я заставил мое приложение запускаться только в ландшафтном режиме вместо портрета. На экране я открываю камеру для записи видео в 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];
Изменяет ориентацию или видео не меняет ориентацию? – Sandeep
, когда я запускаю приложение на пейзаж, ориентация видео не подходит. Кажется, все еще на портрете (верхняя или нижняя кнопка дома). @GeneratorOfOne –