SDAutoLayout icon indicating copy to clipboard operation
SDAutoLayout copied to clipboard

swift UItableViewCell自适应高度及Label高度自适应问题

Open JqyModi opened this issue 7 years ago • 5 comments

能写个swift版本的案例吗?为什么我引入库实现UITableViewCell中label自适应及cell高自适应时item全部重叠显示呢?将tableview的高度直接写死就不会重叠但信息显示不全

JqyModi avatar Sep 22 '17 07:09 JqyModi

我这里也遇到了同样的问题,我用的是 OC,同样出现重叠 @gsdios @lixiang1994

cavanvip avatar Jan 03 '18 02:01 cavanvip

我也遇到上面的问题,关于sd在swift上的使用还是太少了

gsk945 avatar Mar 16 '18 16:03 gsk945

同样,计算返回的cell高度是0, @

harveyseeking avatar Jul 11 '19 06:07 harveyseeking

可以发一下关键代码吗? tableview相关代理和 cell中model处理

lixiang1994 avatar Jul 11 '19 08:07 lixiang1994

同样有问题: cell 和 model类名前都已经添加 @objcMembers了,不然返回高度的代理方法会崩溃 @lixiang1994 @gsdios

代理返回高度:
return tableView.cellHeight(for: indexPath, model: goods, keyPath: "aGoods", cellClass: CustomCell.self, contentViewWidth: SCREEN_WIDTH)

cell中model处理: var aGoods: GoodsModel? {

    didSet {
        
        let url = NSURL(string: (aGoods?.img)!)
        self.goodsImageView?.sd_setImage(with:url! as URL)
        
        self.nameLabel?.text = aGoods?.name
        self.priceLabel?.text = aGoods?.sale_price

       // self.contentView.setupAutoHeight(withBottomViewsArray: [goodsImageView!, priceLabel!], bottomMargin: 5) 
    }
}

AllenYL avatar Jul 30 '19 07:07 AllenYL