Pregunta

Hola tengo este pedazo de código ...

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

y

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

  if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){
    // WTF, this runs when I change to Landscape
  } else {
    // this runs when I change to Portrait??? shouldn't it be the contrary?
  }
}

como se ve, el código se ejecuta en sentido inverso, es decir, la parte del debe ejecutar cuando se cambia el dispositivo de retrato, paisaje de la parte de las carreras de código y viceversa.

Cuando enciendo el dispositivo, gira self.view.

Es esta prueba UIInterfaceOrientationIsPortrait forma en que la interfaz es antes de la rotación o me estoy perdiendo algo?

Gracias por cualquier ayuda.

¿Fue útil?

Solución

Tenga en cuenta que el método se denomina didRotate Desde InterfaceOrientation, por lo que, naturalmente, el parámetro interfaceOrientation se encuentra la vieja orientación, no el nuevo.

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