天天看点

storyboard创建一个用户自定义的cell注意的问题

1. tableviewcell风格选custom

2. identifier必须指定(我的自定义为:dataCellID),cell初始化时必须指定到该identifier

let dataCellID: String = "dataCellID"
var cell = tableView.dequeueReusableCell(withIdentifier: dataCellID)
           

3. 拖入各种控件(label、image)并布好局

4. 每个需要外部改变的控件必须指定Tag(数字可以随意写,别重复就行)。

5. 外部引用时采用如下方式

let cellImage1 = cell?.viewWithTag(1)!as! UIImageView
let cellName = cell?.viewWithTag(2)!as! UILabel