0

I have used the below code to force the view to landscape.

objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationLandscapeLeft);

Is apple approve this for orientation or have any chance to reject my app.Please provide your solution.

Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
Thangavel
  • 216
  • 2
  • 10

1 Answers1

0

I do not think so. Apple documentation state that orientation is read-only property.

To force landscape into ViewController, you can do:

- (NSUInteger)supportedInterfaceOrientations;
{
    return UIInterfaceOrientationMaskLandscape;
}

To present the ViewController in a specified orientation mode:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
{
    return UIInterfaceOrientationLandscapeLeft;
}

For all these to happen, the plist of the project must support the orientation and:

- (BOOL)shouldAutorotate;
{
    return YES;
}

All these is assuming the view controller is not presented under same UINavigationController. For such case, you should refer to this discussion on work around of forcing rotation on UINavigationController: UINavigationController Force Rotate

For views that you want to force into landscape, you can always use transform:

self.view.transform = CGAffineTransformMakeRotation(M_PI/2.0);
Community
  • 1
  • 1
Peter
  • 1,109
  • 7
  • 5