Je rencontre des problèmes avec la taille de l'écran de l'iPhone 5. J'ai créé deux fichiers xib (MainWindow.xib et MainWindowiPhone5.xib) pour que mon application soit compatible avec les deux tailles d'écran.Comment ajouter deux fichiers xib à mon AppDelegate pour prendre en charge les tailles d'écran de l'iPhone?
J'ai essayé de le coder sur mon AppDelegate.m, mais cela ne fonctionne pas.
Voici mon code AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
UIStoryboard *storyBoard;
CGSize result = [[UIScreen mainScreen] bounds].size;
CGFloat scale = [UIScreen mainScreen].scale;
result = CGSizeMake(result.width * scale, result.height * scale);
if(result.height == 1136){
storyBoard = [UIStoryboard storyboardWithName:@"MainWindowiPhone5" bundle:nil];
UIViewController *tabBarController = [storyBoard instantiateInitialViewController];
[self.window.rootViewController = self.tabBarController];
}
}
return YES;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
// Set the tab bar controller as the window's root view controller and display.
self.window.rootViewController = self.tabBarController;
tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor blackColor];
[self.window makeKeyAndVisible];
return YES;
}
Comment puis-je obtenir à la fois de travailler sur xib mon code?
Aidez-nous s'il vous plaît. Merci.
Merci pour la réponse. J'ai essayé d'implémenter le code et j'ai le ** Thread 1: signal SIGABRT ** erreur 'int retVal = UIApplicationMain (argc, argv, nil, nil);'. Dois-je changer quelque chose pour supporter les fichiers ** xib **? – esierr1
Voici le code: 'if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {if ([UIScreen mainScreen] .bounds.size.height == 568) {storyBoard = [UIStoryboard storyboardWithName: @ Paquet" MainWindowiPhone5 ": néant ] } else {if ([[UIScreen mainScreen]]] .size.height == 480) {storyBoard = [UIStoryboard storyboardWithName: @ "Paquet MainWindow": nil]; 'Merci pour votre aide! – esierr1
Vous n'avez pas besoin de prendre 2 storyboards différents. Vous ne pouvez utiliser qu'un seul storyboard et conserver toutes les vues automatiquement. –