Force Landscape iOS 7

force landscape ios 7

Here is how I forced one of my views to be Landscape using NavigationViewController:

  1. Implemented this answer: https://stackoverflow.com/a/12662433/2394787

  2. Imported message in the View controller: objc/message.h

  3. Added this line of code in the viewDidLoad method:

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

Hope it helps someone.

Forcing landscape and autorotate in iOS 7

This solves my problem. I'm not sure why I had issues before, but I must have missed trying this exact combination (also, info.plist should have the supported orientations set).

(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}

(BOOL)shouldAutorotate {
return YES;
}

edit: I may have having issues with the simulator, and doing a reset/restart and clean might have contributed to the fix.

Forcing Landscape Orientation in iOS 7.1 working, not iOS 8.0

It is probably due to a line left over by xcode in your appDelegate.

The following answer contains the line you need to remove:

UISplitViewController rotation iOS8 not working as expected

How can I force landscape for all views in Xcode

After playing around for a while I saw, that the portrait mode is still set in the Build Settings tab even though I disabled it in the General and Info tab. Just click on your Target -> Build Settings -> search for 'Orientation' and remove the portrait one if there is any.

Force landscape mode in one ViewController using Swift

It may be useful for others, I found a way to force the view to launch in landscape mode:

Put this in the viewDidLoad():

let value = UIInterfaceOrientation.landscapeLeft.rawValue
UIDevice.current.setValue(value, forKey: "orientation")

and,

override var shouldAutorotate: Bool {
return true
}


Related Topics



Leave a reply



Submit