Ok, rotation management is a nightmare, let's just accept that :-)

There is no "make it show in landscape" capabilities in IOS, what you have
to do is detect current orientation, compensate for it if needed, then
prompt the user to rotate if you desire.  You must also then dictate to IOS
how the view will or won't rotate via the ShouldAutoRotateToOrientation()
override.  Then, really, you need to understand the view hierarchy and how
it differs between the devices. 

For example
Let's say you have a UIView loaded into a view controller that should ONLY
show in landscape, but the user has launched in portrait - or has navigated
back in portrait mode.  You "could" in the ViewDidLoad or ViewWillAppear
overrides detect the current interface orientation
(this.InterfaceOrientation, for example) and then call a method to "handle
rotation".  The HandleRotation method would then apply a 90degree transform
to the view until such a time as the user rotates the device to the desired
orientation.  

If you find you are in a portrait mode (right-side or up-side down), then
apply a transform to the controller's view
myController.View.Transform =
CGAffingTransform.MakeRotation(-(float)Math.PI/2));

In your ViewWillRotate() or ViewDidRotate() overrides, you could detect that
the user has rotated to a desired orientation, and simply remove the
transform via...
myController.View.Transform = CGAffineTransform.MakeIdentity()

Basically, what I do is have a "HandleRotation()" method defined that
accepts, as a parameter, the "to" orientation.  Then I call that method on
entry to the view controller (in the ViewDidLoad or ViewWillAppear override,
then call it again in the WillRotate() override).

The "HandleRotation" method looks something like...

private void HandleRotation(UIInterfaceOrientation toOrientation)
{
   if(toOrientation == <all the orientations I don't like>)
   {
      View.Transform = CGAffineTransform.MakeRotation(-(float)(Math.PI/2));
   }
   else
   {
       View.Transform = CGAffineTransform.MakeIdentitiy();
    }
}

In your "ShouldAutoRotateToOrientation" override, return "true" for
landscape left and landscape right (in your example), and false for portrait
- that *does not* stop the device from back-navigating or launching into an
unsupported orientation, you still have to deal with that as detailed above. 
If you wanted to get fancy, you could show a Modal/popup with a graphic that
indicates to the user that he/she should rotate to the supported
orientation, after showing your orientation in a rotated state (for example,
let's say you launch in portrait but display the view in a 90 degree
rotation, then show the user a dialog that asks that the device be rotated
to correct the visual representation).

Send me an email @ [email protected] if you want to discuss in greater
detail - more than willing to help - rotation management is not a trivial
thing...



--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/I-think-I-m-missing-something-basic-Please-help-tp4655822p4655851.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to