按照正常的自动布局方式给UIScrollview进行布局的话,子控件不显示,这是由于ScrollView的content size进行自动布局的话须要经过子控件进行约束,则就须要处理好子控件的布局布局
须要注意如下两点:spa
1.子空间根据scrollview的父容器进行约束it
2,固定好子空间的宽高io
demo:table
_scrollView = [[UIScrollView alloc] init];
_scrollView.backgroundColor = [UIColor whiteColor];
_scrollView.delegate = self;
_scrollView.scrollsToTop = NO;
// _scrollView.decelerationRate = UIScrollViewDecelerationRateFast;
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
[self.imagesView addSubview:_scrollView];
[_scrollView autoPinEdgesToSuperviewEdges];
_tableView = [[ZKTableView alloc] init];
_tableView.backgroundColor = [UIColor whiteColor];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.scrollsToTop = NO;
if(IS_IphoneX) {
[_tableView setContentInset:UIEdgeInsetsMake(0, 0, 44 + 20, 0)];
} else {
[_tableView setContentInset:UIEdgeInsetsMake(0, 0, 20, 0)];
}
[self.scrollView addSubview:_tableView];
[_tableView autoPinEdgesToSuperviewEdges];
[_tableView autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self.imagesView];
[_tableView autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.imagesView];ast