Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.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 cellForRowAtIndexPath中的dequeueReusableCellWithIdentifier中的单元格在滚动之前不显示_Ios_Swift_Uitableview - Fatal编程技术网

Ios cellForRowAtIndexPath中的dequeueReusableCellWithIdentifier中的单元格在滚动之前不显示

Ios cellForRowAtIndexPath中的dequeueReusableCellWithIdentifier中的单元格在滚动之前不显示,ios,swift,uitableview,Ios,Swift,Uitableview,我有下面的函数来填充tableview。我正在制作一个数组,获取文本和图像以显示在单元格中。加载该信息时,单元格应显示。但是,单元格在我滚动之前不会显示。问题是什么?如何解决?我看过其他问题,但他们似乎无法回答我的问题,或者我只是不明白他们在说什么 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let

我有下面的函数来填充tableview。我正在制作一个数组,获取文本和图像以显示在单元格中。加载该信息时,单元格应显示。但是,单元格在我滚动之前不会显示。问题是什么?如何解决?我看过其他问题,但他们似乎无法回答我的问题,或者我只是不明白他们在说什么

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! PreviousSongCell

    var song : PreviousSong
    song = self.previousSongs[indexPath.row]

    if (song.artist != "") {
        tableView.userInteractionEnabled = true

        cell.song.text = song.song
        cell.artist.text = "by " + song.artist
        cell.time.text = song.time
        cell.art.image = song.art

        cell.backgroundColor = UIColor.grayColor()
        cell.alpha = 0

        UIView.animateWithDuration(0.15, animations: { cell.alpha = 1 })

    }

    return cell
}

加载数据后调用此选项:

dispatch_async(dispatch_get_main_queue()) {
    self.tableView.reloadData()
}

加载数据后调用此选项:

dispatch_async(dispatch_get_main_queue()) {
    self.tableView.reloadData()
}

第一次显示时是否调用此函数?第一次显示时是否调用此函数?