What are the different storyboards in iOS?

I use two storyboards, the first for the iphone Main.storyboardand the second - Main_iPad.storyboardand I want to call separately for the iPad and iPhone. I am using this code:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)  {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPad" bundle:nil];
    EABaseRootVC *loginController = [storyboard instantiateViewControllerWithIdentifier:@"root2"];
    UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:loginController];
    self.window.rootViewController=navController;
}
else
{

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    EABaseRootVC *loginController = [storyboard instantiateViewControllerWithIdentifier:@"root"];
    UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:loginController];
    self.window.rootViewController=navController;
}

But it always shows iPhone assets for Main.storyboard.

I already follow this Various storyboards for iPhone and iPad in xcode 6

If you have any other idea, please suggest me. what am I doing wrong?

0
source share
1 answer

To identify Apple devices, in particular whether iPhoneor not the iPadcode is used:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
    // code for iPad
}else{
    // code for iPhone
}

And should add these two keys inside your project .plist.

Main storyboard file base name (iPad)
Main storyboard file base name (iPhone)

See image:

enter image description here

0

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


All Articles