4
votes

I'm developing an iOS application, which is actually a wrapper for an existing web application. It adds some additional functionality which can only be achieved this way.

I finished designing the application using size classes and layout constraints. I used one storyboard for both iPhone and iPad. The problem is, I want the iPhone application to be able to only use portrait mode, while the iPad may only use landscape mode (there are different web applications optimized for iPhone and iPad).

Is it possible to do this using only one storyboard, or do I need to use two storyboards (one for iPhone, set to only portrait; and one for iPad, set to only landscape); hence duplicating my design?

3

3 Answers

4
votes

Open your info.plist file as code and paste this code:

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

Works well for me!

2
votes

Yeah, you can do this in iOS8 there is very exciting feature named Adaptive Layout by which The same storyboard can now be used for both iPads and iPhones running iOS 8. There’s no need to keep per-device storyboards in sync with each other.

Here is the very good tutorial on this it will help you out.

-1
votes

Just stick this in your App Delegate:

- (NSUInteger)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return UIInterfaceOrientationMaskLandscape;
    else
        return UIInterfaceOrientationMaskPortrait;
}