Pregunta

¿Cómo mantengo una aplicación de iPhone Monotouch en modo horizontal al cargar un nuevo controlador de vista desde un xib?

Para cambiar al modo horizontal cuando se carga la aplicación, uso:

 app.StatusBarOrientation = UIInterfaceOrientation.LandscapeRight;

Me gustaría poder rotar la vista en el generador de interfaces y diseñar la interfaz. Puedo presionar la flecha de rotación en la esquina de la vista del generador de mi interfaz para rotarlo y guardarlo, pero no afecta a la aplicación cuando se ejecuta.

¿Fue útil?

Solución 2

Este enlace Monotouch rota la vista en Vertical / Paisaje dice usar:

viewRef.transform = CGAffineTransformMakeRotation(angle);

Entonces lo intenté

 this.view.Transform =  CGAffineTransformMakeRotation(3.141f * 0.5f);

Pero obtuve resultados extraños. Resultó que estaba usando .view en lugar de .View. Ahora funciona muy bien con:

 this.View.Transform =  CGAffineTransformMakeRotation(3.141f * 0.5f);

Otros consejos

¿No es aún más fácil usar esto:

public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
    {
        // Return true for supported orientations
        return ((toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown) && (toInterfaceOrientation != UIInterfaceOrientation.Portrait));
    }

De esta forma, solo se autorotará cuando el dispositivo esté en modo horizontal (ambos paisajes)

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