Closed imJithin777 closed 2 years ago
Try to return nil for the "after" and "before" items if the new date is out your date range.
extension ViewController: PagingViewControllerInfiniteDataSource {
func pagingViewController(_: PagingViewController, itemAfter pagingItem: PagingItem) -> PagingItem? {
let calendarItem = pagingItem as! CalendarItem
let endDate = // Your end date
let afterDate = calendarItem.date.addingTimeInterval(86400)
guard afterDate <= endDate else { return nil }
return CalendarItem(date: afterDate)
}
func pagingViewController(_: PagingViewController, itemBefore pagingItem: PagingItem) -> PagingItem? {
let calendarItem = pagingItem as! CalendarItem
let startDate = // Your start date
let beforeDate = calendarItem.date.addingTimeInterval(-86400)
guard beforeDate => startDate else { return nil }
return CalendarItem(date: beforeDate)
}
func pagingViewController(_: PagingViewController, viewControllerFor pagingItem: PagingItem) -> UIViewController {
let calendarItem = pagingItem as! CalendarItem
return CalendarViewController(date: calendarItem.date)
}
}
Can the calendar become finite which starts from today's date to future dates and remove the past days