gpt4 book ai didi

ios - 单元格不显示

转载 作者:行者123 更新时间:2023-11-30 13:53:22 24 4
gpt4 key购买 nike

我有一个非常基本的布局。我只想在我的 uitableview 中显示一个单元格。我提出了同样的问题( Swift Cells Not Displaying ),但现在我已将代码简化为非常基础的内容。

问题:单元格不会显示。如果我将行数设置为 5,它将显示在第三个单元格上,但不会显示在其他单元格上。我已经正确连接了 talbleview。我的单元格标识符命名正确,并且单元格的高度不是问题。

这是我的代码:

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 200.0
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell: ProfileTableViewCell = tableView.dequeueReusableCellWithIdentifier("profileTopCell", forIndexPath: indexPath) as! ProfileTableViewCell

cell.profilePic.image = UIImage(named: "profileImagePlaceholder")

cell.topView.backgroundColor = UIColor(red: 0, green: 155.0/255.0, blue: 0, alpha: 1)
cell.nameLabel.text = PFUser.currentUser()!.objectForKey("Name") as? String
cell.usernameLabel.text = PFUser.currentUser()!.objectForKey("username") as? String
let friendNumber = PFUser.currentUser()!.objectForKey("numberOfFriends") as? Int
if friendNumber != 1{
cell.numberOfFriendsLabel.text = "\(friendNumber!) Friends"
}else{
cell.numberOfFriendsLabel.text = "1 Friend"
}

return cell
}

最佳答案

感谢 Jeremy Andrews ( https://stackoverflow.com/a/31908684/3783946 ),我找到了解决方案:

“您所要做的就是转到文件检查器 - 取消选中尺寸类别 - 将会出现警告等。运行并且有数据 - 奇怪的是 - 返回文件检查器并再次检查“使用尺寸类别”,运行并所有数据都正确反射(reflect)。似乎在某些情况下边距设置为负值。”

这只是一个错误。

关于ios - 单元格不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33976683/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com