Pregunta

Tengo guión gráfico que tiene un controlador de barra de pestañas.Cuando el dispositivo gira, quiero moverme a una pantalla diferente, es decir, no mostrar el mismo diseño de lado, pero muestra algo completamente diferente.

En iOS 5, logré esto con el siguiente código en el UitabBarControllerDelegate

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

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

En iOS 6 este método ya no se llama.Todos los métodos en los que puedo ver cuando se gira la vista , pero no cuando se gira el dispositivo .

gracias de antemano.

¿Fue útil?

Solución

Realmente no debería haber estado buscando una vista de vista , sino un dispositivo .Después de descubrir la clase UIDEVICE, pude usar el código de ejemplo alternativo (solo buscar en el organizador de la documentación) para obtener todo lo que necesitaba.

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

Otros consejos

AutoRotation ha cambiado en iOS 6. Aquí hay un hilo en los foros de Apple Dev en el número: > https://devforums.apple.com/thread/166544?tstartt=30

Aquí hay algunos hilos más: http://www.buzztouch.com/forum/thread.php?tid= 41ed2fc151397d4ad4a5a60 & Currentpage= 1

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

El post más relevante de estos a su problema parece ser el siguiente:

TIENE TRABAJANDO ... PARA APLICACIONES TABLADAS, REEMPLAZA ESTA LÍNEA EN LA APPDELEGATE: [Self.Window AddsubView: [self.rootapp.roottabBarController View]];

con esto: [self.window.rootviewcontroller= self.rootapp.roottabBarController view];

y para obtener aplicaciones no tablas, reemplazó esta línea: [Self.Window AddsubView: [self.rootapp.rootnavcontroller view]];

con esto: [self.window.rootviewcontroller= self.rootapp.rootnavcontroller view];

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top