Question

J'ai le scénario suivant:

De appDelegate je fais:

firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    UINavigationController *firstNavController = [[UINavigationController alloc]initWithRootViewController:firstViewController];

firstViewController - doit être uniquement en mode portrait

Afin d'accomplir ce que j'ai fait:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
   return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (BOOL)shouldAutorotate
{
   return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
   return UIInterfaceOrientationMaskPortrait;
}

À partir de firstViewController Je suis poussant un autre point de vue contrôleur qui doit avoir à la fois portrait et paysage capacités.

L' secondViewController des actes comme prévu dans le portrait et en mode paysage

J'ai des problèmes avec firstViewController qui est affiché en mode paysage trop, si j'ai restreint en mode Portrait.Ce que je fais mal?

Était-ce utile?

La solution

Ajouter l' UINavigationController Catégorie avec la méthode suivante dans votre projet

#import "UINavigationController+MyNavigation.h"

@implementation UINavigationController (MyNavigation)

-(BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

Cela a résolu mon problème.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top