zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    linux之vi编辑器的基础命令
    redis的安装部署启动停止<17.3.21已更新>
    关于Ubuntu的ssh免密登录
    Git(管理修改)
    Git(时光机-版本回退)
    Git(查看修改记录)
    Git(创建版本库)
    集中式VS分布式
    Git(介绍和安装)
    Javascript基础知识
  • 原文地址:https://www.cnblogs.com/Bo-tree/p/5144929.html
Copyright © 2011-2022 走看看