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:
- Have my ShouldAutorotateToInterfaceOrientation returning True.
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.
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.
精彩评论