我使用JTAppleCalendar 7.0在我的应用程序上有一个日历。

但是,相同的代表不起作用。请参考我的要求的屏幕截图。



有人请与我分享示例委托函数。

以下是日历网点的屏幕截图。

Outlets to the calendar

以下是日历的完整代码。

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) {

    }

}

最佳答案

ios - JTAppleCalendar代表不适用于Swift-LMLPHP您实际上忘记了呼叫delegatedataSource。请按照以下步骤调整viewDidLoad():

override func viewDidLoad() {
   super.viewDidLoad()

   calendarView.calendarDataSource = self
   calendarView.calendarDelegate = self

}


ios - JTAppleCalendar代表不适用于Swift-LMLPHP

关于ios - JTAppleCalendar代表不适用于Swift,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51813360/

10-12 00:06