Universal application with Portrait orientation for iPhone and Landscape orientation for iPad

后端 未结 3 1705
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 08:09

I\'m creating a Universal application using Swift. I have used Storyboard and Auto-Layouts. Requirement is of creating a universal application which will support Portrait orient

3条回答
  •  清酒与你
    2021-01-31 08:40

    If you want to set this for a specific ViewController (allow all on iPad but only portrait on iPhone) put this into your ViewController-class (Swift 4):

    override var supportedInterfaceOrientations:UIInterfaceOrientationMask {
        return UIDevice.current.userInterfaceIdiom == .pad ? UIInterfaceOrientationMask.all : UIInterfaceOrientationMask.portrait
    }
    

提交回复
热议问题