![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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