It makes my head.
I am working from this sample project: https://github.com/jj0b/AROverlayExample
It works great. only problem is the portrait app. Therefore, when I rotate the device to the landscape, the video is still displayed as desired, but all my shortcuts and the user interface are now sideways.
To fix this, I set the landscape only in info.plist file
The problem is this:
Here is my code:
- (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; assert( self.autoresizesSubviews ); CGPoint layerRectCenter = CGPointMake( CGRectGetMidX( frame ), CGRectGetMidY( frame ) ); // Initialization code self.captureSession = [[[AVCaptureSession alloc] init] autorelease]; // addVideoInput { AVCaptureDevice* videoDevice = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeVideo]; if (videoDevice) { NSError *error; AVCaptureDeviceInput* videoIn = [AVCaptureDeviceInput deviceInputWithDevice: videoDevice error:&error]; if ( ! error ) { if ( [self.captureSession canAddInput:videoIn] ) [self.captureSession addInput:videoIn]; else NSLog(@"Couldn't add video input"); } else NSLog(@"Couldn't create video input"); } else NSLog(@"Couldn't create video capture device"); } // addVideoPreviewLayer { self.previewLayer = [[[AVCaptureVideoPreviewLayer alloc] initWithSession: self.captureSession] autorelease]; self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; self.previewLayer.frame = CGRectMake(0, 0, 480, 300); self.previewLayer.orientation = AVCaptureVideoOrientationLandscapeRight; //self.previewLayer.frame = frame; [self.layer addSublayer: self.previewLayer]; } // run! [self.captureSession startRunning]; } return self; }
I canβt understand why the video is displayed on the side, and even though setting the layer frame to landscape CGRectMake (0, 0, 480, 300) goes out.
source share