Question

J'ai scénario qui a un contrôleur de barre d'onglets.Lorsque le périphérique tourne, je veux passer à un écran différent, c'est-à-dire pas montrer la même mise en page sur le côté, mais montrer quelque chose de complètement différent.

Dans iOS 5, j'ai obtenu cela avec le code suivant dans l'uitabbarcontrollerdelegate

- (BOOL)shouldAutorotateToInterfaceOrientation:      (UIInterfaceOrientation)interfaceOrientation
{
    if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {    
        [self performSegueWithIdentifier: @"toGraph" sender: self];
    }

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

dans iOS 6 Cette méthode n'est plus appelée.Toutes les méthodes que je peux voir traiter lorsque la View est tournée, mais pas lorsque le périphérique est tourné.

Merci d'avance.

Était-ce utile?

La solution

Donc, vraiment je n'aurais pas dû rechercher une vue la rotation , mais plutôt un périphérique rotation.Après avoir découvert la classe Uidevice, j'ai pu utiliser le code de l'exemple de reviews (juste chercher de nouvellesvoyages dans l'organisateur de la documentation) pour obtenir tout ce dont j'avais besoin.

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.delegate = self;

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)
                                                 name:UIDeviceOrientationDidChangeNotification object:nil];

}

- (void)orientationChanged:(NSNotification *)notification
{
    // We must add a delay here, otherwise we'll swap in the new view
    // too quickly and we'll get an animation glitch
    [self performSelector:@selector(showGraphs) withObject:nil afterDelay:0];
}

- (void)showGraphs
{
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
    if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeView)
    {
        [self performSegueWithIdentifier: @"toGraph" sender: self];
        isShowingLandscapeView = YES;
    }

    else if (deviceOrientation == UIDeviceOrientationPortrait && isShowingLandscapeView)
    {
        [self dismissModalViewControllerAnimated:YES];
        isShowingLandscapeView = NO;
    }
}

Autres conseils

Autotation a changé dans iOS 6. Voici un fil sur les forums d'Apple Dev sur le numéro: https://devforums.apple.com/thread/166544?tStart=30

Voici quelques discussions supplémentaires: http://www.buzztouch.com/forum/thread.php?tid= 41ED2FC151397D4AD4A5A60 & AMP; COURANTPAGE= 1

https://www.buzztouch.com/forum/thread. PHP? FID= B35F4D4F5EF6B293A717EB5 & AMP; TID= B35F4D4F5EF6B293A717EB5

Le poste le plus pertinent de ceux-ci à votre problème semble être le suivant:

Vous avez travaillé ... pour les applications à onglets, remplacée cette ligne dans l'Appdelegate: [Self.Window AddSubview: [auto.rootapp.roottabbarController]];

avec ceci: [self.window.rootviewcontroller= auto.rootapp.roottabbarController];

et pour obtenir des applications non tangées, remplacées cette ligne: [Self.Window AddSubview: [auto.rootapp.rootnavController Voir]];

avec ceci: [self.window.rootviewcontroller= auto.rootapp.rootnavController Voir];

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