问题
I am using two storyboard first one for iphone Main.storyboard and second one is Main_iPad.storyboard and i wants to call separately for 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 its always shows iPhone assets for Main.storyboard.
i am already follow this Different storyboards for iPhone and iPad in xcode 6
if you have any other idea so please suggest me. what i am doing wrong?
回答1:
To identify Apple devices specifically whether it is iPhone or iPad use below code:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
// code for iPad
}else{
// code for iPhone
}
And must add these two keys inside your project's .plist file.
Main storyboard file base name (iPad)
Main storyboard file base name (iPhone)
See image:
来源:https://stackoverflow.com/questions/39594149/how-to-call-different-storyboards-in-ios