gpt4 book ai didi

ios - 我想使用 JTAppleCalendar 库显示一个简单的日历,但它显示一个空屏幕

转载 作者:行者123 更新时间:2023-11-30 10:54:18 25 4
gpt4 key购买 nike

import UIKit
import JTAppleCalendar
class ViewController: UIViewController, JTAppleCalendarViewDelegate, JTAppleCalendarViewDataSource {


let formatter = DateFormatter()

override func viewDidLoad() {
super.viewDidLoad()

}



func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {

let myCustomCell = cell as! JTCustomCell
sharedFunctionToConfigureCell(myCustomCell: myCustomCell, cellState: cellState, date: date)

}

func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "JTCustom", for: indexPath) as! JTCustomCell
self.calendar(calendar, willDisplay: cell, forItemAt: date, cellState: cellState, indexPath: indexPath)
cell.lblDate.text = cellState.text

return cell
}

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: "2019 02 02 ")!
let endDate = formatter.date(from: "2020 01 01")!

let paramaters = ConfigurationParameters(startDate: startDate, endDate: endDate)
return paramaters
}

func sharedFunctionToConfigureCell(myCustomCell: JTCustomCell, cellState: CellState, date: Date) {
myCustomCell.lblDate.text = cellState.text

}


}
//ref: JTAppleCalenderLibray 7.1.6

最佳答案

确保您的集合类在 Identity Inspector 中设置为 JTAppleCalendarView并设置委托(delegate) ibCalendarDataSource 和 ibCalendarDelegate

如果您的日历仍然显示为空白,请在 viewDidLayoutSubviews() 中重新加载

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
calendarView.reloadData()
}

关于ios - 我想使用 JTAppleCalendar 库显示一个简单的日历,但它显示一个空屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54130125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com