zoukankan      html  css  js  c++  java
  • UIScrollView 子控件的自动布局经验

    按照正常的自动布局方式给UIScrollview进行布局的话,子控件不显示,这是因为ScrollView的content size进行自动布局的话需要通过子控件进行约束,则就需要处理好子控件的布局

    需要注意以下两点:

    1.子空间根据scrollview的父容器进行约束

    2,固定好子空间的宽高

    demo:

    _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];

  • 相关阅读:
    宋体、新宋体、仿宋体
    单例模式————你就是我的唯一
    极乐净土代码——第一辑
    泛函是个什么概念
    http和https的区别
    get和post的区别
    浏览器输入URL按回车后都经历了什么?
    求两个列表的交集、并集、差集
    使用lamdba函数对list排序
    乐观锁和悲观锁的区别
  • 原文地址:https://www.cnblogs.com/zrr-notes/p/10900144.html
Copyright © 2011-2022 走看看