我JTAppleCalendar
在我的项目中添加了一些标签,我想在我的一些日历单元格中添加一些标签。我成功添加了它们,但是当我在日历月份向左或向右滚动时,标签内的单元格消失、隐藏或混合,当我一次又一次滚动时,混合的次数越来越多。我需要任何协议或代表等吗?或者,它只是一个错误?
我该如何修复该错误?
我的cellForItemAt
代码:
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell = calendar.dequeueReusableCell(withReuseIdentifier: "CellView", for: indexPath) as! CellView
var currentdate = String(describing: myCalendar.date(byAdding: .day, value: 1, to: cellState.date))
currentdate = currentdate.substring(from: 9, length: 10)
cell.tagList.tags.removeAll()
cell.tagList.hide()
cell.contentView.backgroundColor = nil
cell.tagList.alpha = 0
cell.tagList.numberOfRows = 0
cell.tagList.backgroundColor = UIColor.clear
cell.tagList.isHidden = true
var i : Int
i = 0
for object in datas {
i = i + 1
let clean = "\(object)".components(separatedBy: "*")
if clean[0] == currentdate {
let gotag : Int
gotag = Int(clean[1])!
cell.tagList.isHidden = false
cell.dayLabel.text = cellState.text
cell.contentView.backgroundColor = UIColor.gray
let itemName = "Item name \(i)"
cell.tagList.alpha = 1
if clean[1] == "1" {
cell.tagList.addTag(itemName, target: self, tapAction: #selector(ViewController.tap(_:)), longPressAction: #selector(ViewController.tap(_:)),backgroundColor: UIColor.orange,textColor: UIColor.white,comesTag: gotag)
}else if clean[1] == "2" {
cell.tagList.addTag(itemName, target: self, tapAction: #selector(ViewController.tap(_:)), longPressAction: #selector(ViewController.tap(_:)),backgroundColor: UIColor.green,textColor: UIColor.white,comesTag: gotag)
}else if clean[1] == "3" {
cell.tagList.addTag(itemName, target: self, tapAction: #selector(ViewController.tap(_:)), longPressAction: #selector(ViewController.tap(_:)),backgroundColor: UIColor.brown,textColor: UIColor.white,comesTag: gotag)
}else if clean[1] == "4" {
cell.tagList.addTag(itemName, target: self, tapAction: #selector(ViewController.tap(_:)), longPressAction: #selector(ViewController.tap(_:)),backgroundColor: UIColor.black,textColor: UIColor.white,comesTag: gotag)
}
}else{
cell.tagList.backgroundColor = UIColor.clear
}
}
handleCellConfiguration(cell: cell, cellState: cellState)
return cell
}
行动中的错误:
https://github.com/LetSwiftDev/CalendarBug/blob/master/calendarbug.gif
您也可以在这里加入官方 JTAppleCalendar 聊天 https://gitter.im/patchthecode/JTAppleCalendar