scrollview不能滾動

1. 圖片視圖上不能直接滾動,須要設置交互屬性爲YESide

 

_contentView = [[UIImageView alloc]initWithFrame:CGRectMake(0, _headerView.bottom, kDeviceWidth, kDeviceHeight-20-44-49-_headerView.height-kFooterViewHeight)];ui

_contentView.backgroundColor = [UIColor cyanColor]; _contentView.userInteractionEnabled = YES; [self addSubview:_contentView]; 
orm

2.contentSize 這個屬性,比uiscrollview的frame要小, 無需滾動, 天然就滾動不了。 圖片

3.scrollenabled 這個屬性,標識着是否容許滾動,要言設成yesci

4.由於AutoLayout的影響 -(void)viewDidLayoutSubviews { self.scrollView.contentSize = CGSizeMake(712,1000); }it

另外還有一些比較隱蔽的緣由. 若是這個scrollView是在IB裏面生成的話,還得手動設置它的contentSize,而且不能在initWithNibName:bundle:裏面設置,由於The nib file you specify is not loaded right away. It is loaded the first time the view controller’s view is accessed. If you want to perform additional initialization after the nib file is loaded, override theviewDidLoad method and perform your tasks there.io

相關文章
相關標籤/搜索