Fix rotation issue in landscape mode

I have an application that captures images using AVCapturesession, I have a single View Controller which has a UIView inside and I run the session inside this view.

When my application loads in portrait mode all is good it opens up full screen and on rotation to landscape mode also it remains full screen, Since my view is used to capture an image I am not allowing rotation of only the UIView which is capturing image all is working good.

The only problem is that when my app opens in landscape mode it is not full screen once i rotate it to portrait it gets full screen and then on coming back to landscape it remains full screen.

How can I solve this, or is there a way to force your iOS app to always open in portrait mode and then let it rotate?


I faced the same problem.You should implement this method in your app delegate class. Here is example.Hope this what you need.

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window
    if([window.rootViewController isKindOfClass:[HRMHomeViewController class]])
        id homeViewController = (HRMHomeViewController*)window.rootViewController;
        if ([[homeViewController presentedViewController]
             isKindOfClass:[HRMCapturedScreenViewController class]])
            return UIInterfaceOrientationMaskPortrait;
    return UIInterfaceOrientationMaskAll;

With this method frame of your camera layer will rotate according to orientation

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation
    self.captureManager.cameraLayer.frame = self.videoView.bounds;

There are methods in UINavigationController which can help.Here is two way or make category of UINavigationController or inherit from it.

- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController 
- (UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController 

Need Your Help

Create array of floats from csv Objective C

objective-c arrays csv

I have once again a beginner problem. I have a CSV file that looks something like this:

CALayer and Quartz Transparency

iphone uikit core-animation calayer quartz-graphics

I have a CALayer subclass. I have overridden the drawInContext method. I want the majority of my layer to be transparent except a few areas. I'm using the layer as a menu and I want the icons and