locking orientation does not work on ipad ios 8 swift xcode 6.2
You don't need extra code, I'm working on Xcode 7.0.1, I noticed that when I lock screen orientation to only portrait, it locks only in iPhones, to lock it in iPads also, you need to select iPad from Devices (instead of Universal) and check portrait and uncheck the others and then return Devices to Universal again, as I found that Universal only reflect in iPhones, it maybe some kind of bug in Xcode.
Lock orientation and disable rotation on iPad
The answer to my question was actually quite simple. You have to activate Requires full screen in Deployement Info of your project. After that the iPad behaves the same as the iPhone with this code.
iPad Multitasking support requires these orientations
iPad Multitasking support requires all the orientations but your app does not, so you need to opt out of it, just add the UIRequiresFullScreen
key to your Xcode project’s Info.plist
file and apply the Boolean value YES
.
How to disable auto-rotation for specific View Controllers inside a Navigation Controller (Swift)?
I made an example project on how to do this: GitHub repo.
While @Sidetalker's answer is correct I think it lacks a bit of explanation.
Basically you create a Custom Class for your UINavigationController
and assign it to UINavigationController
in Storyboard. In the custom UINavigationController
class you override
the shouldAutorotate
function and check if the topViewController
is ViewController
(the class of your UIViewController
in Storyboard) of the class on which you want to disable autorotate.
In custom UINavigationController
:
override func shouldAutorotate() -> Bool {
if !viewControllers.isEmpty {
// Check if this ViewController is the one you want to disable roration on
if topViewController!.isKindOfClass(ViewController) {
// If true return false to disable it
return false
}
}
// Else normal rotation enabled
return true
}
Why does my app rotate without animation?
According to UIWindow documentation;
If the window has an existing view hierarchy, the old views are
removed before the new ones are installed.
Source Link -> here
So, system automatically destroy while decide to no longer need your first RootViewController. You can handle transition like this;
if var topRootController = UIApplication.sharedApplication().keyWindow?.rootViewController {
while (topRootController.presentedViewController != nil) {
topRootController = topRootController.presentedViewController!
}
topRootController.presentViewController(homeController, animated: true, completion: nil)
}
Related Topics
Stroke Width with a Scenekit Line Primitive Type
Open App from Sms with My Url Scheme as a Link
What Is the Swift Preprocessor Equivalent to iOS Version Check Comparison
Alert When New Version of iOS App Is Available
Enable Uialertaction of Uialertcontroller Only After Input Is Validated
Array of Multiple Url's Nsfilemanager Swift
Firebase Pod Install - Pod 'Firebase/Database' - Required a Higher Minimum Deployment Target
Hide Red Recording Status Bar in iOS App When Not Recording
How to Do Authorization and Login with Wechat Using the iOS Sdk
How to Start an Ibeacon Transmitter in the Background
Shrink Large Title When Scrolling (Not Uitableviewcontroller) iOS 11
JSON Parsing Using Nsjsonserialization in iOS
Share Datas Between Two Apps with iOS 8 App Groups (Using Nsuserdefaults)
Xcode Error:Distill Failed for Unknown Reasons