美文网首页
swift cell自适应高度

swift cell自适应高度

作者: 舰_966e | 来源:发表于2021-05-19 08:28 被阅读0次

    overridefunc viewDidLoad() {

    super.viewDidLoad() self.tableView.estimatedRowHeight =100

        self.tableView.rowHeight = UITableViewAutomaticDimension

    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    ...... 

                cell.textLabel?.numberOfLines =0 

                cell.textLabel?.preferredMaxLayoutWidth= CGRectGetWidth(tableView.bounds) 

    }

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

        return UITableViewAutomaticDimension

    }

    相关文章

      网友评论

          本文标题:swift cell自适应高度

          本文链接:https://www.haomeiwen.com/subject/cfwujltx.html