Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用xib和autolayout的自定义UITableViewCell无法在顶部的几个单元格中正确显示_Ios_Uitableview_Swift_Autolayout_Xib - Fatal编程技术网

Ios 使用xib和autolayout的自定义UITableViewCell无法在顶部的几个单元格中正确显示

Ios 使用xib和autolayout的自定义UITableViewCell无法在顶部的几个单元格中正确显示,ios,uitableview,swift,autolayout,xib,Ios,Uitableview,Swift,Autolayout,Xib,我使用了名为“SCTableViewCell”的自定义UITableViewCell,并与“CustomCell.xib”链接并加载到“CenterViewController” 当它运行时,顶部的几个单元格看起来不好(如下图),在向下滚动屏幕并再次向上滚动(坏单元格一旦消失并再次出现)后,看起来很好 它是自定义单元类 SCTableViewCell.swift class SCTableViewCell: UITableViewCell { @IBOutlet weak var th

我使用了名为“SCTableViewCell”的自定义UITableViewCell,并与“CustomCell.xib”链接并加载到“CenterViewController”

当它运行时,顶部的几个单元格看起来不好(如下图),在向下滚动屏幕并再次向上滚动(坏单元格一旦消失并再次出现)后,看起来很好

它是自定义单元类 SCTableViewCell.swift

class SCTableViewCell: UITableViewCell {

    @IBOutlet weak var thumbnailImage : UIImageView!
    @IBOutlet weak var titleLabel : UILabel!
    @IBOutlet weak  var descLabel : UILabel!

    func loadItem(#title: String, desc: String, image: UIImage){

        titleLabel.text = title
        descLabel.text = desc
        thumbnailImage.image = image
        self.contentView.setTranslatesAutoresizingMaskIntoConstraints(true)
    }

    override func layoutSubviews() {
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
和CenterViewController.swift

override func viewDidLoad() {
    super.viewDidLoad()        
    //Setting Custom Tableview Cell
    self.tableView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "CustomCell")
}

   func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier("CustomCell", forIndexPath: indexPath) as SCTableViewCell

            cell.loadItem(title: title!, desc: desc!, image: pic)
            cell.updateConstraints()

            return cell
    }
控制台没有显示任何内容。。。。 请帮帮我

哦! 我没有设置我的手机高度。。。哈哈

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return 160
}
已添加到CenterViewController.swift中,并且可以正常工作