Question

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.

Was it helpful?

Solution

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"];

OTHER TIPS

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.

In Swift 3.0 :

if let orientationArray = Bundle.main.infoDictionary?["UISupportedInterfaceOrientations"] as? [String] {
   // Your Code here
}

How about Info.plist UISupportedInterfaceOrientations?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top