Pregunta

Tengo un UIViewController simple que utiliza un XI ter por su interfaz.

Como tal, la interfaz comprende simplemente un UIView, un UIActivityIndicator y una UILabel. Tengo las limitaciones de tamaño en el Interface Builder establecen para mantener el indicador de actividad y la etiqueta centrada cuando la vista gira.

El UIViewController tiene previsto regresar SÍ para orientación vertical y horizontal en el método -shouldAutorotateToInterfaceOrientation:.

Se añade el fin de la jerarquía de vistas manualmente, utilizando

if (!activityOverlay)
    activityOverlay = [[XBActivityOverlayViewController alloc] initWithNibName:@"XBActivityOverlayViewController" bundle:nil message:@"Connecting..."];

[activityOverlay.view setAlpha:0.0f];
[self.window addSubview:activityOverlay.view];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3f];
[activityOverlay.view setAlpha:0.9f];
[UIView commitAnimations];

El problema que estoy teniendo es que si el dispositivo ya está en orientación horizontal y se añade el punto de vista de la jerarquía en este punto, la vista es todavía en orientación vertical, y no auto rotación.

¿Qué necesito hacer para añadir la vista en la misma orientación que la vista padre?

¿Fue útil?

Solución

No sé si es la respuesta correcta a su pregunta, pero espero que pueda ayudar a:

Para mí, cada vez que añadir / despedir a un modal o mostrar un nuevo punto de vista, la siguiente función se llama:

-(void) detectOrientation 
{


 if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) || 
     ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) 
 {

             item1.frame = CGRectMake(147.0, 241.0, 56.0, 28.0);
     item2.frame = CGRectMake(265.0, 241.0, 56.0, 28.0);

 }
 else if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) ||
          ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) || !inLandscapeOrientation)
 {

    item1.frame = CGRectMake(35.0, 425.0, 35.0, 28.0);
item2.frame = CGRectMake(176.0, 425.0, 35.0, 28.0);
 }

}

Aquí cambio de la posición de acuerdo con la orientación del dispositivo actual. Tal vez si detecta que la orientación actual es el paisaje se agrega una vista secundaria que tiene dicha orientación.

Alejandra:)

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