vishnu_146
vishnu_146

Reputation: 466

Splash screen orientation lock

Can we have the orientation locked for splash screen in potrait for the app that supports all orientations?Currenly when I launch the app while device is landscape makes the splash screen looking really ugly,and I need it only in portrait.

Upvotes: 13

Views: 5330

Answers (3)

Vladislav Komkov
Vladislav Komkov

Reputation: 41

Answer based on @vishnu_146's comment:

  1. Set Portrait orientation in info.plist
  2. Then set desired orientation in AppDelegate (you can set specific orientations for iPad and iPhone)
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
    let orientations: UIInterfaceOrientationMask = UIDevice.current.userInterfaceIdiom == .pad ? .all : [.portrait, .landscape]
    return orientations
}

Upvotes: 1

Xander43
Xander43

Reputation: 164

If you would like to use a launch screen storyboard in a single orientation, change the info.plist to specify that orientation only.

Then if you would like to have the app run different orientations after the launch screen storyboard has finished, then simply add the following method to your app delegate (objective-c):

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    UIInterfaceOrientationMask theMaskToReturn = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | "etcetera";

    return  theMaskToReturn;
}

Then use a single navigation controller for your entire app (and if you subclass this single navigation controller it must have the same masktoreturn as above).

Then in each VC you can specify the supported orientations.

Note that if you are sharing via MFMailComposer or an ActivityVC which are both presented from self in a VC, then the masktoreturn must include the permissible orientations.

Upvotes: 14

davidethell
davidethell

Reputation: 12018

The only way to lock the splash screen into portrait orientation is if the supported orientations for the app are set to portrait alone.

Upvotes: 5

Related Questions