[super viewDidLoad]; [self.view addSubview:self.scrollView]; [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.left.right.mas_equalTo(0); -(UIScrollView *)scrollView{ if (!_scrollView) { _scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; _scrollView.contentSize = CGSizeMake(0,700); return _scrollView;

解决方法 1

ViewController里面添加下面这个方法

-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    //在这里设置一下 不然滚动不了
    self.scrollView.contentSize = CGSizeMake(0,700);

解决方法 2

UIScrollView+Masonry 自适应宽高

164.8k
粉丝