Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

esthervanenckevort/Rotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Rotation

Example project to show how to control the rotation of your application's view controllers.

Based on Swift 100 Days: Project 24 - How To Rotate Only One ViewController to Landscape Orientation?. This version is using protocols and extensions and

Files of interest

Implementation

  1. Create the UIViewController extension to determine the top most presented view controller.
  2. Create the RotationEnabled protocol to mark each ViewController that supports rotation.
  3. Implement in the AppDelegate the method func application(UIApplication, supportedInterfaceOrientationsFor: UIWindow?) -> UIInterfaceOrientationMask to report the supported orientations.
  4. Mark each view controller that should support rotation with the RotationEnabled protocol and implement the canRotate requirement and add code to viewWillDisappear to reset the rotation to portrait when the view will disappear from the screen. if (self.isMovingFromParent) { UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation") }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages