我有一个数组,其中包含用户回复帖子的评论,它们保存在 Parse.com 中,但是当我尝试在 tableView 中显示它们时,它们似乎没有显示。这就是我用来在 tableView 中显示评论的内容。
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("commentCell", forIndexPath: indexPath) as! CommentTableViewCell
cell.commentLabel?.text = comments![indexPath.row] as String
return cell
}
我已经尝试了代码的其他一些变体和此处的其他一些帖子试图找到答案,但仍然没有运气。 我可以确认数据保存在 Parse 中,但它似乎没有显示在应用程序中。我做错了什么?
最佳答案
您忘记配置 tableview 数据源。
class DetailViewContoller: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextViewDelegate {
...
...
...
override func viewDidLoad() {
super.viewDidLoad()
commentTableView.delegate = self
commentTableView.dataSource = self
要使用tableview,您必须配置tableview委托(delegate)和数据源。
关于ios - UITableView 不显示标签,也不显示单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32430167/