I encountered this exact problem in the past myself. I was able to solve this using simple operation (and GPUImage ). My code is in Objective-C, but Iβm sure itβs easy for you to translate it into Swift.
I started by installing project-supported rotations to everything I was hoping to support, and then overriding the same UIViewController methods:
-(BOOL)shouldAutorotate { return TRUE; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }
Allows the device to rotate, but will be saved in portrait mode. Then he began to observe the rotation of the device:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(adjustForRotation:) name:UIDeviceOrientationDidChangeNotification object:nil];
Then he updated the user interface if the device was in portrait mode or in landscape orientation:
-(void)adjustForRotation:(NSNotification*)notification { UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; switch (orientation) { case UIDeviceOrientationLandscapeLeft: {
And finally, GPUImage displayed an image based on the orientation of the device.
[_gpuImageStillCamera capturePhotoAsImageProcessedUpToFilter:last_f withCompletionHandler:^(UIImage *processedImage, NSError *error) {
source share