0

I know that I can select available orientation of my app in targets menu, but I would like to block landscape orientation for each screen EXCEPT the one with youtube player.

I suppose this couldn't be done via app delegate since it does not distinct controllers and apply the rule for the whole app.

I suspect maybe there is a way to do that via sharedApplication(), but have no clue how to.

Do you have any idea how such thing could be done?

Eric Aya
  • 69,000
  • 34
  • 174
  • 243
theDC
  • 6,194
  • 8
  • 53
  • 95

2 Answers2

1

Use this override func in each VC you want to block .LandscapeLeft and .LandscapeRight

override func supportedInterfaceOrientations() -> Int {
    return Int(UIInterfaceOrientationMask.Portrait.rawValue) | Int(UIInterfaceOrientationMask.PortraitUpsideDown.rawValue)
}
Chameleon
  • 1,558
  • 3
  • 20
  • 38
1

Add this to the UIViewController class you wish to set to Portrait only.

override func supportedInterfaceOrientations() -> Int {
  return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}

Provided you haven't changed any settings in your target the other screens without this should be able to rotate correctly.

Chackle
  • 2,241
  • 14
  • 32