You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

配置UITableViewCell时遇到高度布局异常问题求助

UITableViewCell布局高度异常问题

配置UITableViewCell时遇到布局问题,具体表现为高度异常。以下是相关信息:

  • 视图控制器截图:视图控制器截图
  • 包含Cell的Xib文件截图:Xib文件截图
  • 当前运行效果截图:运行效果截图
  • 视图控制器代码:
class BooksListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    @IBOutlet weak var searchBar: UISearchBar!
    @IBOutlet weak var booksTableView: UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setView()
    }
    
    private func setView() {
        searchBar.placeholder = "Поиск"
        booksTableView.delegate = self
        booksTableView.dataSource = self
        booksTableView.register(UINib(nibName: "BooksTableViewCell", bundle: nil), forCellReuseIdentifier: "bookCell")
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = booksTableView.dequeueReusableCell(withIdentifier: "bookCell", for: indexPath) as? BooksTableViewCell else {return UITableViewCell()}
   
        return cell
    }
}

内容的提问来源于stack exchange,提问作者aLikan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 02:27:16