0

I have a view controller whose view has a container view as a subview. I set the initial frame of the container view in IB and later change it according to if an iAd loaded in a banner. If I add another subview to the view controller's view the container view's frame gets resized back to the frame set in IB.

I have no idea why this is happening and appreciate any help. I created a test app to eliminate all of the other variables so I know this is the situation.

4

1 回答 1

2

当您使用自动布局时,您无法设置从 xib 或故事板加载的视图框架。自动布局设置框架,并忽略您对框架所做的更改。如果您需要直接移动或调整它们的大小,则需要更新这些视图的约束。

您可以在视图控制器中创建一个指向 an 的出口NSLayoutConstraint,并将出口连接到您的 xib 或情节提要中的适当约束。然后你可以改变约束的constant属性来改变视图的位置或高度。

于 2013-08-07T16:55:35.043 回答