個人比較喜歡用OC創(chuàng)建標(biāo)識喜歡用NSStringFromClass([self class]),這樣生命標(biāo)識比較簡單,沒那么多代碼
xib注冊方法 及故事版
swift中用 String(describing:SwiftHomeTableCell.self) 可以達(dá)到跟NSStringFromClass([self class])同樣的效果
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing:SwiftHomeTableCell.self))
故事版
let storyboard = UIStoryboard.init(name: "SwiftHome", bundle: Bundle.main);
storyboard.instantiateViewController(withIdentifier: String(describing: SwiftHomeController.self))
需要傳值進(jìn)入cell的話需要這樣寫
? ? ? ? let cell = tableView.dequeueReusableCell(withIdentifier:
String(describing:SwiftHomeTableCell.self)) as?SwiftHomeTableCell 加上
as?SwiftHomeTableCell 強(qiáng)轉(zhuǎn)成你創(chuàng)建測cell
純代碼創(chuàng)建
self.tableView.register(ViewControllerCell.classForCoder(), forCellReuseIdentifier: NSStringFromClass(ViewControllerCell.classForCoder()))
這樣寫NSStringFromClass(ViewControllerCell.classForCoder())跟 NSStringFromClass([self class])效果一樣但在Xib不可以這樣寫故事版上創(chuàng)建同樣不可以