Dans votre délégué application, vous devez ajouter/remplacer le code suivant dans - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_4inch" bundle:nil];
} else {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
}
où ViewController_4inch
est le nom du fichier nib qui est conçu pour l'iPhone 5 écran
MISE à JOUR (ANSWER storyboard spécifique):
Pour charger différents storyboards sur le lancement, utilisez ce code:
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height == 480)
{
// Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35
UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_iPhone35" bundle:nil];
// Instantiate the initial view controller object from the storyboard
UIViewController *initialViewController = [iPhone35Storyboard instantiateInitialViewController];
// Instantiate a UIWindow object and initialize it with the screen size of the iOS device
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Set the initial view controller to be the root view controller of the window object
self.window.rootViewController = initialViewController;
// Set the window object to be the key window and show it
[self.window makeKeyAndVisible];
}
if (iOSDeviceScreenSize.height == 568)
{ // iPhone 5 and iPod Touch 5th generation: 4 inch screen
// Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4
UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_iPhone4" bundle:nil];
UIViewController *initialViewController = [iPhone4Storyboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = initialViewController;
[self.window makeKeyAndVisible];
}
Une petite recherche aurait permis de découvrir beaucoup d'informations. Essayez http://stackoverflow.com/a/12397309/300292. – rsswtmr
En fait, j'ai vu ces solutions, le mode boîte aux lettres ou la refonte en utilisant le code basé sur la taille de l'écran. Mais je veux concevoir un StoryBoards séparé pour les écrans de hauteur 1136 et 960. Nous pouvons avoir des storyboards séparés pour iPad et iPhone en utilisant pList. Mais je veux savoir, est-il possible de charger différents storyboards pour iPhone 5 et iPhone 4S .... ??? – iSaalis
Et que se passe-t-il lorsque le prochain iPhone est 1280x1024? Ou un mini iPad de taille similaire apparaît? Mon point est que vous devez sortir de l'habitude de concevoir pour chaque facteur de forme et commencer à utiliser les nouveaux outils de contrainte de mise en page. Imaginez que vous deviez repenser une application PC pour chaque résolution d'écran possible ... – rsswtmr