我的应用程序上有一个使用JTAppleCalendar 7.0的日历。
然而,同样的委托并不起作用。请参考我的需求截图。

有没有人可以和我分享一下委托函数的示例。
下面是日历上的插座截图。
下面是日历的完整代码。
import UIKit
import JTAppleCalendar
class CalendarViewController: UIViewController, JTAppleCalendarViewDelegate, JTAppleCalendarViewDataSource {
@IBOutlet weak var calendarView: JTAppleCalendarView!
let formatter = DateFormatter()
override func viewDidLoad() {
super.viewDidLoad()
}
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
formatter.dateFormat = "yyyy MM dd"
formatter.timeZone = Calendar.current.timeZone
formatter.locale = Calendar.current.locale
let startDate = formatter.date(from: "2018 08 10")!
let endDate = formatter.date(from: "2018 10 10")!
let parameters = ConfigurationParameters(startDate: startDate, endDate: endDate)
return parameters
}
func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {
let dateCell = cell as! DateCell
dateCell.dateLabel.text = cellState.text
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
if let cell = calendarView.dequeueReusableJTAppleCell(withReuseIdentifier: "dateCell", for: indexPath) as? DateCell {
cell.dateLabel.text = cellState.text
cell.configure(date: cellState.text)
return cell
}
return DateCell()
}
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell, cellState: CellState) {
guard let validCell = cell as? DateCell else { return }
validCell.contentView.backgroundColor = UIColor.black
}
func calendar(_ calendar: JTAppleCalendarView, didDeselectDate date: Date, cell: JTAppleCell, cellState: CellState) {
}
}发布于 2018-08-14 01:24:22

你实际上忘了给delegate和dataSource打电话。请按如下方式调整viewDidLoad():
override func viewDidLoad() {
super.viewDidLoad()
calendarView.calendarDataSource = self
calendarView.calendarDelegate = self
}

https://stackoverflow.com/questions/51813360
复制相似问题