2012-09-21 3 views
0

J'utilise ce code pour adapter mon story-board selon l'appareil (iPhone 5 ou moins):iPhone 5 écran adapter

if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){ 
    if(UIScreenOverscanCompensationScale==1136/640){ 
     //move to your iphone5 storyboard 
     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iphone5 storyboard" bundle:[NSBundle mainBundle]]; 
    } 
    else{ 
     //move to your iphone4s storyboard 
     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]]; 
    }} 

Le code ne fonctionne pas, même si je viens place:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iphone5 storyboard" bundle:[NSBundle mainBundle]]; 

... il charge toujours l'iphone normal.

je l'ai mis sous:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 

délégué à l'application. Est-ce correct?? Dans les paramètres de l'application que j'ai choisi l'iPhone original story-board

+1

Sur la page Cibles Résumé du story-board est probablement réglé sur MainStoryboard_iPhone –

Répondre

0

j'ai réussi à le résoudre de cette façon:

if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){ 
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568.0){ 
     //move to your iphone5 storyboard 
     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iphone5 storyboard" bundle:[NSBundle mainBundle]]; 
     UIViewController *vc =[storyboard instantiateInitialViewController]; 

     // Set root view controller and make windows visible 
     self.window.rootViewController = vc; 
     [self.window makeKeyAndVisible]; 
    } 
    else{ 
     //move to your iphone4s storyboard 
     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]]; 
     UIViewController *vc =[storyboard instantiateInitialViewController]; 

     // Set root view controller and make windows visible 
     self.window.rootViewController = vc; 
     [self.window makeKeyAndVisible]; 
    }} 
+0

où dois-je mettre ce code? appDelegate ?? –

0

Le problème est que:

UIScreenOverscanCompensationScale==1136/640 

ne sera jamais vrai.

Vérifiez ce que fait UIScreenOverscanCompensationScale et renvoyez un BOOL.

+0

oui mais le code n'est pas appelé tout bien – Alessandro

0

Est-ce que MainStoryboard est toujours spécifié sous le résumé cible? Je crois que ce sera là où l'application regarde en premier.

+0

, j'ai décidé sur un storyboard sous sommaire => storyboard principal. parce que je dois décider d'un storyboard. – Alessandro