首页 > 编程语言 > 详细

swift UITableView cell自适应高度

时间:2016-01-06 23:11:59      阅读:545      评论:1      收藏:0      [点我收藏+]

swift UITableView cell自适应高度

ios8支持:

1.

override func viewDidLoad() {  
    super.viewDidLoad()  
      
    self.tableView.estimatedRowHeight = 100  
    self.tableView.rowHeight = UITableViewAutomaticDimension  
}  

2.

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {  
......  
            cell.textLabel?.numberOfLines = 0  
            cell.textLabel?.preferredMaxLayoutWidth = CGRectGetWidth(tableView.bounds)  
}  

3.

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {  
    return UITableViewAutomaticDimension  
}  

 

swift UITableView cell自适应高度

原文:http://www.cnblogs.com/OrangesChen/p/5107521.html

(0)
(0)
   
举报
评论 一句话评论(1
2018-01-17 10:08:54
我是自定义的标签该怎么设置内容的自适应,,往楼主告知,感谢
回复
 (2)
 (0)
1条  
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!