scrollview不能滚动

1. 图片视图上不能直接滚动,需要设置交互属性为YES

 

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

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


2.contentSize 这个属性,比uiscrollview的frame要小, 无需滚动, 自然就滚动不了。 

3.scrollenabled 这个属性,标识着是否允许滚动,要言设成yes

4.因为AutoLayout的影响 -(void)viewDidLayoutSubviews { self.scrollView.contentSize = CGSizeMake(712,1000); }

另外还有一些比较隐蔽的原因. 如果这个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.

转载于:https://www.cnblogs.com/Bo-tree/p/5144929.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值