Custom Cell Row Height setting in storyboard is not responding

后端 未结 18 2079
名媛妹妹
名媛妹妹 2020-11-30 16:54

I am trying to adjust the cell height for one of the cells on my table view. I am adjusting the size from the \"row height\" setting inside the \"size inspector\" of the cel

18条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 17:38

    If you're using swift , use like this. Don't Use storyboard to select row height. Programmatically set table row height like this,

     func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        if indexPath.row == 0 || indexPath.row == 1{
            let cell = self.tableView.dequeueReusableCellWithIdentifier("section1", forIndexPath: indexPath) as! Section1TableViewCell
            self.tableView.rowHeight = 150
            cell.label1.text = "hiiiiii"
            cell.label2.text = "Huiiilllllll"
            return cell
    
        } else {
    
            let cell = self.tableView.dequeueReusableCellWithIdentifier("section2", forIndexPath: indexPath) as! Section2TableViewCell
            self.tableView.rowHeight = 60
            cell.label3.text = "llll"
            return cell
        }
    
    }
    

提交回复
热议问题