IOS Autolayout ScrollView无法滚动的解决办法
参考资料:
http://www.cocoachina.com/bbs/read.php?tid=175749
问题:
设定autolayout之后,发现scrollview无法滚动了,导致无法查看所有的内容。在viewDidLoad里重新设定scrollview的contentSize,还是不行。
原因:
viewDidLoad时,autolayout还没有运行,所以设置了之后。等autolayout运行之后,还是被初始化为autolayout预设值了。
解决办法:
在viewDidAppear里重新设置contentSize,例如:
- (
void
)viewDidAppear:(
BOOL
)animated
{
[
super
viewDidAppear:animated];
self
.scrollView.contentSize =
self
.imageView.image.size;
self
.imageView.frame = CGRectMake(0, 0,
self
.imageView.image.size.width,
self
.imageView.image.size.height);
}