0

La vue juste après l'écran de lancement doit être présentée dans l'orientation de l'appareil, mais ne doit pas s'orienter vers d'autres orientations une fois qu'elle est présentée. J'ai utilisé ce code:Prise en charge de toutes les orientations sans autorotate dans l'iPhone

- (BOOL)shouldAutorotate { 

    [super shouldAutorotate]; 

    return YES; 
} 

-(UIInterfaceOrientationMask) supportedInterfaceOrientations { 

    [super supportedInterfaceOrientations]; 

    return UIInterfaceOrientationMaskAll; 
} 

Cela fonctionne bien pour iPad mais iPhone, NO pour la mise en shouldAutorotate résultats en mode portrait uniquement. Est-ce que c'est un comportement normal? Si oui, comment toutes les orientations peuvent-elles être prises en charge sans autorotation dans l'iPhone, pour un contrôleur de vue particulier uniquement?

Répondre

0

Vous devez détecter quelle orientation l'appareil est lorsque vous démarrez:

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 

convertir en une orientation de l'interface:

switch (orientation) { 
    case UIDeviceOrientationLandscapeRight: 
     return UIInterfaceOrientationLandscapeLeft; 
    default: 
     return UIInterfaceOrientationLandscapeRight; 
} 

stocker Maintenant quelque part pour un accès mondial et de retour que :

- (UIInterfaceOrientationMask) supportedInterfaceOrientations { 
    return globalOrientation; 
}