How to force view controller orientation in iOS 8?

前端 未结 25 2068
太阳男子
太阳男子 2020-11-22 13:11

Before iOS 8, we used below code in conjunction with supportedInterfaceOrientations and shouldAutoRotate delegate methods to force app orie

25条回答
  •  粉色の甜心
    2020-11-22 13:13

    The top solution above:

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

    didnt'work for me when I called it in viewDidAppear of the presented view controller. However it did work when I called it in preparForSegue in the presenting view controller.

    (Sorry, not enough reputation points to comment on that solution, so I had to add it like this)

提交回复
热议问题