Reputation: 12194
I am working on a third party library that can go into any app. My library provides functionality that depends on what orientations are supported within an app. I am wondering if there is any reliable, programmatic way to retrieve the list of supported app orientations in any given app. This is important so that I may be able to modify what functionality is available for my library based on what orientations are supported.
Note: Considering this is a library, I need to be able to consult one reliable place for this information.
Upvotes: 0
Views: 253
Reputation: 2021
In Swift 3.0 :
if let orientationArray = Bundle.main.infoDictionary?["UISupportedInterfaceOrientations"] as? [String] {
// Your Code here
}
Upvotes: 1
Reputation: 21244
Take a look at application:supportedInterfaceOrientationsForWindow:
in the UIApplicationDelegate
protocol. From your comments it should meet your needs. If the application does not implement that method, fall back to the information in the Info.plist.
Upvotes: 1
Reputation: 408
You can read your Info.plist as a dictionary with
[[NSBundle mainBundle] infoDictionary]
And you can easily get the supported orientations at the UISupportedInterfaceOrientations
key that way.
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSArray* supportedOrientations = [infoDict objectForKey:@"UISupportedInterfaceOrientations"];
Upvotes: 2