app to be portaraint and particular screen will be landscape swift

 Problem:

I had enabled portrait and landscape in info.plist but i want to enable one screen in landscape allowed and other screens only on portrait.How to achieve that?


Solution:

First you must enable the both portrait and landscape in info.plist.Then add the below code in appdelegate

    func application(_ application: UIApplicationsupportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {

        if let vc = UIApplication.topViewController() as? myviewController {

            // Only allow portrait (standard behaviour)

            print("landscape called")

            return .all;

        }

        print("portrait called")

        return .portrait;

    }


Then it will be working fine.Happy coding..

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift