为什么数组未在表格视图中显示? [英] Why is the array not showing up in the table view?

查看:58
本文介绍了为什么数组未在表格视图中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要将解析后的数据附加到数组中,但是当我尝试在表视图中加载数组时,什么也没有显示。数组已填充,但未显示任何内容。我该如何解决?

I am appending data from parse into an array, but when I try to load array in table view nothing shows up. The array is populated, but nothing is showing up. How do I fix this?

class View2: UIViewController, UITableViewDataSource, UITableViewDelegate{

  var ret = [String]()

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

    return ret.count
  }

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

    let cell = table.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) 

    cell.textLabel?.text = ret[indexPath.row]

    return cell
   }
}


推荐答案

设置 ret值后,必须重新加载表。

After set 'ret' value, you have to reload table.

在我的情况下,

var ret = [String](){
    didSet{
        self.tableView.reloadData()
    }
}

这篇关于为什么数组未在表格视图中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆