Peter Hornsby
Peter Hornsby

Reputation: 4266

How to disable rotation animation for iPhone and iPad devices

I have used the following code from these questions to disable the rotation animation. It works for for iPhone devices but does not work for iPads.

The view controller in question is the root view controller of a navigation controller that is being presented modally.

Does anyone know why the following method would work on an iPhone but not an iPad?

 override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {

    coordinator.animate(alongsideTransition: nil) { _ in UIView.setAnimationsEnabled(true) }

    UIView.setAnimationsEnabled(false)

    super.viewWillTransition(to: size, with: coordinator)
}

StackOverflow Questions

Disable orientation change rotation animation

In 7.3/9/2+ Swift how to disable rotation animation, when device rotates?

Upvotes: 1

Views: 1637

Answers (2)

Peter Hornsby
Peter Hornsby

Reputation: 4266

From my testing it appears that you can disable the rotation animation for iPhones but when it comes to the iPad the animation is handled by the system and there is no possibility to interact with it.

So I would conclude that you cannot disable the rotation animation on an iPad given the current public api's.

Upvotes: 1

Artem Aleksandrov
Artem Aleksandrov

Reputation: 352

it could not work because size of screen is not changed on rotation of ipad (or changing not significantly). I've had a problem with this method once i turned off portrait orientation of one screen. My fix was to catch device orientation by observing for a notification. But in this case you will have only "did rotate" state.

Upvotes: 0

Related Questions