3月30日编辑 - 注意:使用Monotouch。当我旋转到LandscapeRight / Left时,我想改变一些按钮的位置。这是我正在尝试的:
在我的WillRotate中(我也试过把它放在DidRotate中)它没有显示任何区别,这是我的代码:
public override void WillRotate(UIInterfaceOrientation toInterfaceOrientation,double duration) { //作为测试,将其中一个按钮移动到与应有位置不同的位置 System.Drawing.RectangleF rect = new System.Drawing.RectangleF(40,1, btn2.Bounds.Width,btn2.Bounds.Height); btn2.Bounds = rect; }
我认为改变边界可能不是正确的方法,但鉴于Bounds.X和Bounds.Y是不可变的,这是我找到改变位置的唯一方法。
答案 0 :(得分:2)
这就是你想要的......
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
可以找到here。
想法是在确定移动方向后调整想要移动的任何物体的X和Y.