新建cell:
使用:
let cellIdentifier : String = "DayCell"
chartsTableView!.registerNib(UINib(nibName: "GoalsVitalsDayTableViewCell", bundle:nil), forCellReuseIdentifier: cellIdentifier)
let cell : GoalsVitalsDayTableViewCell = chartsTableView!.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! GoalsVitalsDayTableViewCell
(1)向 tableview 注册 nib全局变量
let cellIdentifier = "myCell"
myTableView!.registerNib(UINib(nibName: "MyCell", bundle:nil), forCellReuseIdentifier: cellIdentifier)
(2)然后在 cellForRowAtIndexPath 方法中使用:
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath:NSIndexPath!) -> UITableViewCell!{ var mycell: GoalsVitalsDayTableViewCell = tableView!.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as GoalsVitalsDayTableViewCell
return mycell
}
至此,一个简单地自定义cell已经实现!