force landscape ios 7
Here is how I forced one of my views to be Landscape using NavigationViewController:
Implemented this answer: https://stackoverflow.com/a/12662433/2394787
Imported message in the View controller: objc/message.h
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
How Detect Swipe Gesture Direction
Get Country Code from Country Name in iOS
Launch Other Application Without Url Schema in Iphone
How to Draw a Point Using Core Graphics
Uiscrollview Pauses Nstimer While Scrolling
How to Set Action for Uibutton in Uitableviewcell
Cabasicanimation Resets to Initial Value After Animation Completes
iOS 7 Uitableview: How to Remove Space Between Navigation Bar and First Cell
Add Cocoapods to Tests Target Too
Simulate Universal Gravitation for Two Sprite Kit Nodes
Perform a Deeplink from Swiftui Widget on Tap
Swift iOS9 New Contacts Framework - How to Retrieve Only Cncontact That Has a Valid Email Address
Play Audio from Internet Using Avaudioplayer
How to Enable "Tap and Slide" in a Uislider
JSON Text Did Not Start with Array or Object and Option to Allow Fragments Not Set