当superView frameWidth更改时,UIView不会自动调整大小

时间:2012-07-20 17:28:18

标签: iphone objective-c ios ipad uiview

所以我有一个名为footerView的UIView,它被添加到UIScrollView中。我按如下方式初始化它:

 UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.scrollView_.frameWidth, kFooterViewHeight)];
    [footerView setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin];
    [footerView setBackgroundColor:[UIColor clearColor]];
 self.footerView_ = footerView;
    [self.scrollView_ setFooterView_:self.footerView_];
    [footerView release];

所以最初scrollView.frameWidth设置为768.但是稍后它被调整为450.在这之后我尝试检查self.footerView.frameWidth并且它仍然是768.为什么这样?  我试过在footerView上调用setNeedsLayout,我确保在UIScrollView上设置自动调整大小视图,但没有任何反应。

1 个答案:

答案 0 :(得分:0)

您同时设置,灵活的边距和灵活的宽度。如果需要,可以调整视图大小,避免灵活的边距。