UITableView tableFooterView autolayout自动计算高度


    UIView *tableFooter = [UIView new];
    self.tableView.tableFooterView = tableFooter;
    
    UILabel *footerLabel = [UILabel new];
    footerLabel.numberOfLines = 0;
    footerLabel.backgroundColor = [UIColor redColor];
    [tableFooter addSubview:footerLabel];
    
  //UITableView 不能给 tableFooterView添加约束,但可给其子view添加约束 [footerLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(tableFooter).mas_offset([NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)]); }]; footerLabel.preferredMaxLayoutWidth = CGRectGetWidth([UIScreen mainScreen].bounds) - 20; footerLabel.text = @"[footerLabel mas_makeConstraints:^(MASConstraintMaker *make) {\ make.edges.mas_equalTo(tableFooter).mas_offset([NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)]);\ }];";

//计算tableFooterView的size CGSize size = [tableFooter systemLayoutSizeFittingSize:CGSizeMake([UIScreen mainScreen].bounds.size.width, 1000)]; tableFooter.frame = CGRectMake(0, 0, size.width, size.height); self.tableView.tableFooterView = tableFooter;

  

http://prod.lists.apple.com/archives/cocoa-dev/2014/Jun/msg00131.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM