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

  • 相关阅读:
    C#线程并发执行的实例[转]
    Win7怎么用IIS发布网站系统 部署项目
    C#:用SqlBulkCopy来实现批量插入数据
    jQuery 中post 、get的同步问题
    网页配色颜色表(推荐)
    如何修改eclipse的默认字符集和修改中文乱码
    eclipse学习
    SpringMVC开发流程
    SpringMVC的请求
    SpringMVC的数据响应
  • 原文地址:https://www.cnblogs.com/zrr-notes/p/10900144.html
Copyright © 2011-2022 走看看