AlexBerd
AlexBerd

Reputation: 1504

xCode: Force orientation for iPad

I have application for iPhone's and iPad. However, for iPad I have to force it for landscape only and for iPhone I have no restrictions.

As I understand such solution can not be done via device orientation property in project properties, which I have to choice all for iPhone, and have to be via code.

I am a new one in Swift and will glad to get some explanations.

Upvotes: 0

Views: 101

Answers (2)

AlexBerd
AlexBerd

Reputation: 1504

I found those options in Info.plist Works great! enter image description here

Upvotes: 0

Shehata Gamal
Shehata Gamal

Reputation: 100503

You can try something like

    if(UIDevice.currentDevice().userInterfaceIdiom == .Pad){

        let value = UIInterfaceOrientation.LandscapeRight.rawValue
        UIDevice.currentDevice().setValue(value, forKey: "orientation")


    }

Upvotes: 1

Related Questions