0

我正在使用 AutoresizingMask 以编程方式定义相对位置。我得到了几乎所有的工作,但我不知道如何在两个元素之间保持相同的分隔(UIButton,UILabel 由 20px 分隔)这就是我所拥有的:

UIButton , 定位在 (100, 100), 大小: 60x30, autoresizingMask=UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin

UILabel,定位在 (180,100),大小:50x50,autoresizingMask=UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin

我的问题是,当方向改变时,我无法在这两个元素之间保持 20px 的边距。

4

1 回答 1

1

我经常发现在改变方向时我需要对我的 UI 做更多的“调整”,而不是自动发生的事情。

您可以将此例程添加到您的控制器,并以您喜欢的方式微调您的 UI:

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) o {
   -- Set the label to be 20px to the right of your button here
}
于 2011-12-12T19:31:07.263 回答