3

I need to restrict my share extension to be in portrait mode only. But so far, it is not okay. Is there a way to do?

@implementation UINavigationController

-(BOOL)shouldAutorotate
{
     return UIInterfaceOrientationMaskPortrait;
}

-(NSUInteger)supportedInterfaceOrientations
{
     return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
     return UIInterfaceOrientationPortrait;
}
Khant Thu Linn
  • 5,905
  • 7
  • 52
  • 120

1 Answers1

1

You can extend UIScreen, like in answer here

And to perform in

   - (void)viewDidLayoutSubviews of UIViewController.

Something like in answer here

Code from the first link looks like that in Objective-C:

    - (UIInterfaceOrientation) orientation {

CGPoint p = [self.coordinateSpace convertPoint: CGPointZero toCoordinateSpace: self.fixedCoordinateSpace];

if (CGPointEqualToPoint(p, CGPointZero)) {
    return UIInterfaceOrientationPortrait;
} else {

    if (p.x != 0 && p.y != 0) {
        return UIInterfaceOrientationPortraitUpsideDown;
    } else {
        if (p.x == 0 && p.y != 0) {
            return UIInterfaceOrientationLandscapeLeft;
        } else {
            if (p.x != 0 && p.y == 0) {
                return UIInterfaceOrientationLandscapeRight;
            } else {
                return UIInterfaceOrientationUnknown;
            }
        }
    }
}

return UIInterfaceOrientationUnknown;

}

Community
  • 1
  • 1