繁体   English   中英

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

[英]UIView not autoresizing when the superView frameWidth changes

所以我有一个名为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上设置了自动调整大小的视图,但没有任何反应。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM