【发布时间】:2020-06-17 12:00:03
【问题描述】:
我在UICollectionViewCell 中有一个FSCalendar 视图,该视图已连接且功能正常。但是,当在 viewController 的扩展中调用 didSelect 日期函数时,没有任何动作(不调用打印函数)。是否需要将特定引用传递给 CellForIndexPath 才能调用此函数?
分机代码:
extension CalendarViewController: FSCalendarDelegate, FSCalendarDataSource {
func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {
print("Date selected")
}
}
自定义单元格:
class ChartCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var calendarView: FSCalendar!
}
CollectionView cellForItemAt 代码:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.item == 0 {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "chartCell", for: indexPath) as! ChartCollectionViewCell
return cell
}
}
【问题讨论】:
标签: ios swift uicollectionview uicollectionviewcell fscalendar