即使实现了委托方法,也会出现“不符合JTAppleCalendarViewDelegate”错误

时间:2017-09-23 00:10:49

标签: ios swift jtapplecalendar

这是JTAppleCalendar委托和数据源方法实现的整个扩展部分。

extension ViewController : JTAppleCalendarViewDelegate, JTAppleCalendarViewDataSource {
  func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
    // set date formatter
    formatter.dateFormat = "yyyy MM dd"
    formatter.timeZone = Calendar.current.timeZone
    formatter.locale = Calendar.current.locale

    let startDate = Date()
    let endDate = (Calendar.current as NSCalendar).date(byAdding: .day, value: 180, to: startDate, options: [])!

    let parameters = ConfigurationParameters(startDate: startDate, endDate: endDate)
    return parameters
  }
  func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
    let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "DateCell", for: indexPath) as! AccountsDateCell
    cell.dateLabel.text = cellState.text
    return cell
  }
}

Xcode说:

  

类型'ViewController'不符合协议'JTAppleCalendarViewDelegate'

看起来问题在于手动安装库。我将文件拖放到这个项目中。有没有其他方法可以手动将库添加到项目中?

1 个答案:

答案 0 :(得分:1)

您必须实施configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters委托方法。

如果您使用的是Xcode 9,它应该为您插入所需的功能存根。