专业java、php、iOS、C++、网页设计、平面设计、网络营销、游戏开发、前端与移动开发培训机构

自定义HMStatusCell

  • 自定义 HMStatusCell 显示 显示原创微博 内容
  • 创建 HMStatusOriginalCell.xib, 并设置内容
  • 关联 HMStatusOriginalCell.xibCellHMStatusCell
  • 拖线 HMStatusOriginalCell.xibHMStatusCell
  • HMHomeViewController 注册 HMStatusOriginalCell.xibtableView, 并设置 tableViewrowHeightestimatedRowHeight

    override func viewDidLoad() {
      super.viewDidLoad()
      ...
    
      // 注册可重用 cell
      tableView.register(UINib(nibName: "HMStatusOriginalCell", bundle: nil), forCellReuseIdentifier: "OriginalCell")
      tableView.rowHeight = UITableViewAutomaticDimension
      tableView.estimatedRowHeight = 200
    
      ...
    }
    
  • HMHomeViewControllertableView 获取到 自定义的Cell

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: "OriginalCell", for: indexPath) as! HMStatusCell
    
      return cell
    }
    
  • 运行: 效果如下

results matching ""

    No results matching ""