iOS 14 SDK app running on M1 Mac to use layout for a specific device

Viewed 222

I used an iOS iPhone only app I developed on a M1 Mac, my app seemed to have recognized the screen size as an iPhone 4s.

I have specific code to read the device screen size and ensure that the appropriate layout for the device is used. So for instance...

#define IS_IPHONE ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)

#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)

#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_ZOOMED (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)

#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
#define IS_IPHONE_X (IS_IPHONE && SCREEN_MAX_LENGTH == 812.0)

#define IS_IPHONE_12 (IS_IPHONE && SCREEN_MAX_LENGTH == 844.0)
#define IS_IPHONE_12Max (IS_IPHONE && SCREEN_MAX_LENGTH == 926.0)

later on in code...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    
    ViewController *controller;

    if (IS_IPHONE_12)
    {
        _navigationController = (UINavigationController *)self.window.rootViewController;
        
        // Instantiate a new storyboard object using the storyboard file for iPhoneX
        UIStoryboard *iPhone12Storyboard = [UIStoryboard storyboardWithName:@"Main12" bundle:nil];
        NSLog(@"Using Main12 storyboard");
        
        UIViewController *initialViewController = [iPhone12Storyboard instantiateInitialViewController];
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        
        self.window.rootViewController  = initialViewController;
        
        controller = (ViewController *)_navigationController.topViewController;
        controller.managedObjectContext = self.managedObjectContext;
        
        [self.window makeKeyAndVisible];
    }}

is there a way to code it so if its running on an M1 Mac the app uses the iPhone 12 Pro layout?

0 Answers
Related