UITableView没有按顺序显示SWIFT

时间:2016-01-04 22:10:18

标签: ios json swift uitableview

对tableview有一些问题。 JSon内容的顺序是正确的,但是当我在问题开始时更新表格时。这是我更新表格的方式:

var cats = [Categories]()

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

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    cats.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cellIdentifier = "CategoryTableViewCell"
    let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! CategoryTableViewCell
        print(cats[indexPath.row].categoryName)
        cell.nameLabel.text = cats[indexPath.row].categoryName
        cell.subNameLabel.text = cats[indexPath.row].appShortDesc
    return cell
}

当我打印JSon时,它显示正确的顺序,只是tableview继续做它的感觉。

0 个答案:

没有答案
相关问题