Duplication in values of tableView when Scrolling Swift

后端 未结 3 1200
情深已故
情深已故 2021-01-14 06:33

I have a tableView to display timings of week days

timingsArray is used in tableView to display timings

timingsArray of type timingObj

cla         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 07:13

    You should implement prepareForReuse in your custom cell class, in which you reset what needs to be reset. For example:

    class timingCell: UITableViewCell {
    
        @IBOutlet weak var dayLabel: UILabel!
    
        @IBOutlet weak var timeLabel: UILabel!
    
        func prepareForReuse() {
            super.prepareForReuse()
            cell.timeLabel.text = nil
            cell.dayLabel.text = nil
        }
    }

提交回复
热议问题