Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to lock Screen Orientation programmatically in iOS?
You might come across a scenario where you need to show the UI in a specific orientation may be Landscape or Portrait.
We will be seeing how to lock orientation programmatically using Swift in iOS.
Open Xcode → New Project → ViewController.swift write the below code.
// Set the shouldAutorotate to False
override open var shouldAutorotate: Bool {
return false
}
// Specify the orientation.
override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}

Advertisements
