[英]How to display events when clicking a date on calendar
I am using JTAppleCalendar for an app where users will be able to schedule events/reminders on the calendar. 我将JTAppleCalendar用于应用程序,用户可以在日历上安排事件/提醒。 I am having a difficult time trying to get this functionality to get built. 我很难尝试构建此功能。 Ideally, when a user clicks on a certain date on the calendar, an area at the bottom of the calendar would show the event details pertaining to that day. 理想情况下,当用户单击日历上的某个日期时,日历底部的区域将显示与该日期有关的事件详细信息。
I am completely clueless as to where i would even begin. 我什至不知道该从哪里开始。
If I understood correctly, you want to respond to cell selection events. 如果我理解正确,则您想响应单元格选择事件。
It's similar to how UICollectionView/TableView works: You need to implement the delegate which in this case is called JTAppleCalendarViewDelegate
. 它类似于UICollectionView / TableView的工作原理:您需要实现委托,在这种情况下,该委托称为JTAppleCalendarViewDelegate
。 The method you are looking for is calendar(_:didSelectDate:cell:cellState:)
which Tells the delegate that a date-cell with a specified date was selected . 您要查找的方法是calendar(_:didSelectDate:cell:cellState:)
,它告诉委托人已选择具有指定日期的日期单元格 。
class CalendarViewController: JTAppleCalendarViewDelegate {
func viewDidLoad() {
super.viewDidLoad()
calendarView.delegate = self
}
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
// Do something.
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.