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