专业java、php、iOS、C++、网页设计、平面设计、网络营销、游戏开发、前端与移动开发培训机构
自定义HMStatusCell
- 自定义
HMStatusCell显示显示原创微博内容 - 创建
HMStatusOriginalCell.xib, 并设置内容 
- 关联
HMStatusOriginalCell.xib的Cell为HMStatusCell - 拖线
HMStatusOriginalCell.xib到HMStatusCell 
在
HMHomeViewController注册HMStatusOriginalCell.xib到tableView, 并设置tableView的rowHeight和estimatedRowHeightoverride func viewDidLoad() { super.viewDidLoad() ... // 注册可重用 cell tableView.register(UINib(nibName: "HMStatusOriginalCell", bundle: nil), forCellReuseIdentifier: "OriginalCell") tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 200 ... }在
HMHomeViewController的tableView获取到自定义的Celloverride func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "OriginalCell", for: indexPath) as! HMStatusCell return cell }- 运行: 效果如下
