Доступ к функции FSCalendar внутри пользовательской ячейки - PullRequest
0 голосов
/ 17 июня 2020

У меня есть вид FSCalendar внутри UICollectionViewCell, который подключен и работает. Однако при вызове функции даты didSelect в расширении viewController ничего не происходит (функция печати не вызывается). Требуется ли конкретная ссылка c для передачи в 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
        }
   }

1 Ответ

1 голос
/ 17 июня 2020

Добавьте эту строку внутрь cellForItemAt

cell.calendarView.delegate = self
...