固定两个方向上的对象之间的空间

时间:2011-12-12 19:26:14

标签: ios interface-builder autoresizingmask

我正在使用AutoresizingMask以编程方式定义相对位置。我几乎所有工作都有效,但我无法弄清楚如何保持两个元素之间的相同分离(UIButton,UILabel以20px分隔) 这就是我所拥有的:

  

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

     

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

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

1 个答案:

答案 0 :(得分:1)

我经常发现,在更改方向时,我需要对UI进行一些“调整”,而不是自动执行。

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

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) o {
   -- Set the label to be 20px to the right of your button here
}
相关问题