小编Rah*_*yat的帖子

如何在Swift中以编程方式设置UITableView单元格高度

如何以编程方式设置视图高度我已经尝试此代码

cell.viewMain.frame = CGRectMake(cell.viewMain.frame.origin.x, cell.viewMain.frame.origin.y, cell.viewMain.frame.size.width, 65.0)
Run Code Online (Sandbox Code Playgroud)

但这不起作用.

更新:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("updateCell", forIndexPath: indexPath) as! UpdateCell

    if self.data[indexPath.row] == "b" {
        tbUpdate.rowHeight = 85
        cell.viewMain.frame = CGRectMake(cell.viewMain.frame.origin.x, cell.viewMain.frame.origin.y, cell.viewMain.frame.size.width, 65.0)
    }else{
        tbUpdate.rowHeight = 220
        cell.viewMain.frame = CGRectMake(cell.viewMain.frame.origin.x, cell.viewMain.frame.origin.y, cell.viewMain.frame.size.width, 200.0)
    }

    return cell
}
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

8
推荐指数
4
解决办法
2万
查看次数

标签 统计

ios ×1

swift ×1

uitableview ×1