2012-10-05 19 views
15

Duplicar posibles:
How to develop or migrate apps for iPhone 5 screen resolution?Historietas separados para iPhone 5 y iPhone 4S

¿Cómo puedo cargar guiones gráficos separados para iPhone 5 y iPhone 4S/4/3G ??

I wana hacer esto porque el tamaño de pantalla es diferente para iPhone 5.

+0

Un poco de búsqueda habría descubierto una gran cantidad de información. Pruebe http://stackoverflow.com/a/12397309/300292. – rsswtmr

+0

En realidad, he visto esas soluciones, modo buzón o rediseño utilizando código basado en el tamaño de la pantalla. Pero quiero diseñar un StoryBoards separado para pantallas de 1136 y 960 de altura. Podemos tener storyboards separados para iPad y iPhone usando pList. Pero quiero saber si es posible cargar diferentes storyboards para iPhone 5 y iPhone 4S .... ??? – iSaalis

+2

¿Y qué sucede cuando el próximo iPhone es 1280x1024? ¿O aparece un mini iPad de tamaño similar? Mi punto es que debes deshacerte del hábito de diseñar para cada factor de forma y comenzar a usar las nuevas herramientas de restricción de diseño. Imagine si tiene que rediseñar una aplicación de PC para cada resolución de pantalla posible ... – rsswtmr

Respuesta

32

En delegado de la aplicación, se necesita añadir/reemplazar el código siguiente en - (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]; 
} 

donde ViewController_4inch es el nombre del archivo semilla que está diseñado para el iPhone 5 pantalla

ACTUALIZACIÓN (RESPUESTA GUIÓN-específico):

Para cargar diferentes guiones gráficos en el lanzamiento, utilice este código:

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]; 
    } 
+0

no responde mi pregunta ... ¿Cómo puede la misma aplicación cargar storyboards separados para iPhone 5 y iPhone 4S/4/3G? – iSaalis

+0

@iSaalis por favor revisa mi respuesta actualizada. –

+0

¿no debería el iphone 4 (s) screensize.height estar configurado == 968? – Chris

Cuestiones relacionadas