how to register a cell for UITableViewCell
2016-07-04 12:24
351 查看
storyboard method and api two methods: registerClass() and registerNib()
tableView.registerClass(FriendTableViewCell.self, forCellReuseIdentifier: NSStringFromClass(FriendTableViewCell))
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: NSStringFromClass(UITableViewCell))
//default CellIndentifier is “UITableViewCell”, so NSStringFromClass(UITableViewCell) is “UITableViewCell”
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: “DefaultCell”)
tableView.registerNib(UINib(nibName: “NibName”, bundle: nil), forCellReuseIdentifier: “CellFromNib”)// NibName is Xib file and this Xib must connect to a custom class ,for example StarTableViewCell
Use:
let cell = tableView.dequeueReusableCellWithIdentifier(NSStringFromClass(FriendTableViewCell), forIndexPath: indexPath) as! FriendTableViewCell
let cell = tableView.dequeueReusableCellWithIdentifier(“UITableViewCell”)! as UITableViewCell
let cell = tableView.dequeueReusableCellWithIdentifier(“DefaultCell”)! as UITableViewCell
let cell:UITableViewCell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier:”Cell”)
var starCell: StarTableViewCell! = tableView.dequeueReusableCellWithIdentifier(identifier) as? StarTableViewCell
tableView.registerClass(FriendTableViewCell.self, forCellReuseIdentifier: NSStringFromClass(FriendTableViewCell))
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: NSStringFromClass(UITableViewCell))
//default CellIndentifier is “UITableViewCell”, so NSStringFromClass(UITableViewCell) is “UITableViewCell”
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: “DefaultCell”)
tableView.registerNib(UINib(nibName: “NibName”, bundle: nil), forCellReuseIdentifier: “CellFromNib”)// NibName is Xib file and this Xib must connect to a custom class ,for example StarTableViewCell
Use:
let cell = tableView.dequeueReusableCellWithIdentifier(NSStringFromClass(FriendTableViewCell), forIndexPath: indexPath) as! FriendTableViewCell
let cell = tableView.dequeueReusableCellWithIdentifier(“UITableViewCell”)! as UITableViewCell
let cell = tableView.dequeueReusableCellWithIdentifier(“DefaultCell”)! as UITableViewCell
let cell:UITableViewCell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier:”Cell”)
var starCell: StarTableViewCell! = tableView.dequeueReusableCellWithIdentifier(identifier) as? StarTableViewCell
相关文章推荐
- ❀❀ 名词解释(PM、PD、UE、UI、RD....)
- 07.LoT.UI 前后台通用框架分解系列之——轻巧的文本编辑器
- Facebook开源的基于SQL的操作系统检测和监控框架:osquery daemon详解
- UITableView获取cell的indexPath
- request.getAttribute() 和 request.getParameter() 有何区别?
- 加快AS的Gradle Build速度
- 【UI】RecyclerView的使用
- 设置UIButton最多显示几行《三》
- 在xib上给UIView添加边框或圆角
- EasyUI Tree默认全部折叠,通过传入ID判断展开节点并选中
- Android 与 IOS的UUID的区别
- EasyUi弹窗提示!
- maven打包时,同时打包源码 Build a source-JAR from the current project.
- 设置UIButton最多显示几行《二》
- HDU 5412 CRB and Queries (Kth number 整体二分 动态转静态)
- Android View系统源码分析(十三)—— View.requestFocus() & ViewRoot.requestLayout()
- The project was not built due to "Could not delete ...".Fix the problem, then try refreshing this project and building it since it may be inconsistent.
- AR识别场景中UI被挡住的问题
- ugui基础控件button使用(二)
- build\tools\buildinfo.sh