2011-09-02 3 views
2

iPad fonctionne très bien pour le portrait, mais ne fonctionne pas pour le paysage,application iPad fonctionne pas pour le mode paysage

J'utilise ce code

- (BOOL) isPad{ 
#ifdef UI_USER_INTERFACE_IDIOM 
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad); 
#else 
    return NO; 
#endif 
} 


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    if ([self isPad]) { 

     return YES; 
    } 
    else 
    { 
     return UIInterfaceOrientationIsPortrait(interfaceOrientation); 
    } 

} 


- (BOOL)isPadLandscape 
{ 

    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad 
      && (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight 
       || self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft)); 

} 

- (BOOL)isPadPortrait 
{ 

    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad 
      && (self.interfaceOrientation == UIInterfaceOrientationPortrait 
       || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)); 
} 




- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if ([self isPadPortrait]) 
    { 
     [imageView setFrame:CGRectMake(0, -50, 768, 1024)];   
    } 
    else if ([self isPadLandscape]) 
    { 
     [imageView setFrame:CGRectMake(0, 0, 1024, 768)]; 
    } 
} 

je tente d'appeler - (BOOL) méthode isPadLandscape pendant le débogage, mais cette méthode n'appeler,

Quoi de mal?

+0

Si son une application iPad alors pourquoi est-il dans le titre « iPhone »? Vous devriez vous assurer que ce que vous tapez a vraiment du sens. Assurez-vous toujours de spécifier les balises dans le champ des balises seulement, sauf qu'il est vraiment utile de les mettre dans le titre. – EmptyStack

Répondre

2

Ne pas oublier de définir la propriété Supported interface orientations (iPad) dans votre fichier Info.plist pour les postes pris en charge appropriées.

Ou essayez ceci:

- (BOOL) isPad{ 
    return [[UIDevice currentDevice].model hasPrefix:@"iPad"]; 
} 
+0

J'ai déjà défini cette propriété. –

+0

Essayez de remplacer la méthode 'isPad' par la mienne. – Nekto

+0

i utilisé votre méthode de fin d'appel de méthode, mais quand je fais un mode paysage application à ce moment - (BOOL) isPadLandscape peut appeler, mais cette méthode n'appeler. –

Questions connexes