开发者

Changing X & Y of Button upon Rotation

开发者 https://www.devze.com 2022-12-24 08:14 出处:网络
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:

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号