首页 > 解决方案 > TableViewCell 未完全显示

问题描述

我的 TableViewCells 在 Xcode 中看起来很正常,但在模拟器中显示时会被截断。请看下面的图片。

有谁知道这是为什么?

任何帮助深表感谢!

Xcode 图片:

在此处输入图像描述

模拟器图像:

在此处输入图像描述

class Feed: UITableViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    UIApplication.shared.isStatusBarHidden = false
}

override open func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    //It will hide the status bar again after dismiss
    UIApplication.shared.isStatusBarHidden = false
}
override open var prefersStatusBarHidden: Bool {
    return false
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

// MARK: - Table view data source

override func numberOfSections(in tableView: UITableView) -> Int {
    // #warning Incomplete implementation, return the number of sections
    return 1
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // #warning Incomplete implementation, return the number of rows
    return 1
}


override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! FeedCell

    // Configure the cell...

    return cell
}

标签: iosswiftuitableviewcell

解决方案


使用tableView(_:heightForRowAt:). 根据要求添加高度。


推荐阅读