Universal orientation apps for iPhone / iPad

I am working on an application that is a universal application. Now I want to set the orientation for both methods. When the application launches on the iPhone, then it opens in portrait mode and when the application launches on the iPad then opens in landscape mode.

Is it possible?

+4
source share
4 answers
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && UIInterfaceOrientationIsLandscape(interfaceOrientation)) { return YES; } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && UIInterfaceOrientationIsPortrait(interfaceOrientation)) { return YES; } return NO; } 
+5
source
 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // The device is an iPad running iPhone 3.2 or later. // Rotate to landscape } else { // The device is an iPhone or iPod touch. // Rotate to portrait } 

" How to get UI_USER_INTERFACE_IDOM to work with iOS 3.2?

+2
source

You can also use [UIDevice currentDevice] .model or [UIDevice currentDevice] .systemName to recognize the device, and then in the return toAutoRotate method returnOrientation == UIInterfaceOrientationLandscapeLeft for the ipad and interfaceOrientation == UIInterfaceOrientation based devicePortrait.

0
source

You can do this by adding code to the delegate of your application for my answer here .

Quick code:

 func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> Int { if UIDevice.currentDevice().userInterfaceIdiom == .Phone { return Int(UIInterfaceOrientationMask.Portrait.rawValue) } else { return Int(UIInterfaceOrientationMask.LandscapeLeft.rawValue | UIInterfaceOrientationMask.LandscapeRight.rawValue) } } 
0
source

Source: https://habr.com/ru/post/1341015/


All Articles