Domanda

Ho storyboard che ha un controller per barra.Quando il dispositivo ruota che voglio spostare su uno schermo diverso, I.e. Non mostrare lo stesso layout lateralmente, ma mostra qualcosa di completamente diverso.

In iOS 5 L'ho raggiunto con il seguente codice nell'utitabbarcontrollegate

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

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}
.

In IOS 6 Questo metodo non è più chiamato.Tutti i metodi che posso vedere Affrontare quando è ruotato View , ma non quando il dispositivo viene ruotato.

Grazie in anticipo.

È stato utile?

Soluzione

Quindi non avrei dovuto cercare una rotazione view , ma piuttosto un dispositivo rotazione.Dopo aver scoperto la classe UIDEVICE sono stato in grado di utilizzare il codice di esempio alternatoreviews (basta cercare AlternateViews nell'organizzatore di documentazione) per ottenere tutto ciò di cui avevo bisogno.

- (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;
    }
}
.

Altri suggerimenti

L'autorotazione è cambiata in iOS 6. Ecco un thread sui forum di Apple Dev sul problema: https://devforum.apple.com/thread/166544?tstart=30

Ecco alcuni thread: http://www.buzztouch.com/forum/thread.php?tid= 41ED2FC151397D4AD4A5A60 e AMP; CurrentPage= 1

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

Il post più rilevante da questi al tuo problema sembra essere il seguente:

.

ha capito ... Per le app a schede, ha sostituito questa riga nell'Appdelegate: [Self.Window AddsubView: [self.rootapp.roottabbarcontroller Visualizzazione]];

Con questo: [self.window.rootviewcontroller= self.rootapp.roottabbarcontroller Visualizzazione];

E per ottenere app non a schede, ha sostituito questa riga: [Self.Window AddsubView: [self.rootapp.rootnavcontroller Visualizzazione]];

Con questo: [self.window.rootviewcontroller= self.rootapp.rootnavcontroller Visualizzazione];

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top