2011-12-12 89 views
0

我正在使用AutoresizingMask以编程方式定义相对位置。我得到了几乎所有的工作,但我无法弄清楚如何保持两个元素(UIButton的,的UILabel由20像素分开) 这是我之间相同的分离:在两个方向上的对象之间的固定空间

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

的UILabel,位于(180,100),尺寸:50×50,autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin

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

回答

1

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

可以将该程序添加到您的控制器,并微调您的用户界面的方式,你喜欢:

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