Skip to content

Commit 55d1fe1

Browse files
committed
更新 cell 获取方法
1 parent 66b1477 commit 55d1fe1

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

CornerRadius/CornerRadius/ViewController.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
2727

2828
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
2929
let identifier = "tableviewcell"
30-
var cell = table.dequeueReusableCellWithIdentifier(identifier) as? CustomTableViewCell
31-
if cell == nil {
32-
cell = CustomTableViewCell(style: .Default, reuseIdentifier: identifier)
33-
cell?.selectionStyle = .None
34-
}
35-
30+
table.registerClass(CustomTableViewCell.self, forCellReuseIdentifier: identifier)
31+
let cell = table.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as? CustomTableViewCell
32+
33+
cell?.selectionStyle = .None
3634
cell?.setupContent(imgName: "photo")
3735

3836
return cell!

0 commit comments

Comments
 (0)