views:

145

answers:

1

Edited Mar 30 - Note: Monotouch used. When I rotate to LandscapeRight/Left I want to change the location of some of my buttons. Here's what I'm trying:

  1. Have my ShouldAutorotateToInterfaceOrientation returning True.
  2. In my WillRotate (I tried putting this in DidRotate as well) it doesn't show any difference, here's my code:

    public override void WillRotate (UIInterfaceOrientation toInterfaceOrientation, double duration) { // As a test move one of the buttons somewhere different than where it should be System.Drawing.RectangleF rect = new System.Drawing.RectangleF(40, 1, btn2.Bounds.Width, btn2.Bounds.Height); btn2.Bounds = rect; }

I figure that changing the bounds may not be the right way, but given that the Bounds.X and Bounds.Y are immutable, this was the only way I could find to change the position.

+2  A: 

This is what you want...

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

It can be found here.

The idea is to adjust the X and Y of any objects you want to move around after you determine the direction of the move.

Jordan
You're speaking Cocoa, but the OP is developing in C# (monotouch)
Shaggy Frog
Oh, ok. stop developing in C# and learn cocoa ;)
Jordan
WillRotate and DidRotate map to this, however when they fire and I change the X and Y of a button, it doesn't actually change where the button is shown. I must be missing something.
Driss Zouak
Useless comment, Jordan.
Eduardo Scoz
Eduardo, The smiley face indicates I was joking. Get a life. (notice the lack of smiley face).
Jordan
Putting the smiley war aside, can I actually get an answer to my revised question please? What are the proper properties to alter on a button for X and Y? Either in Objective-C or MonoTouch, I'll figure it out from there.
Driss Zouak