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,473
  • 35
  • 181
  • 253
theDC
  • 6,364
  • 10
  • 56
  • 98

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,608
  • 3
  • 21
  • 39
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,249
  • 18
  • 34