Как выбрать календарную дату в JKCalendar внутри ячейки табличного представления - PullRequest
0 голосов
/ 16 февраля 2020

Я хочу спросить. Я хочу выбрать день в JKCalendar или в календаре внутри ячейки табличного представления, и я понял, что в ячейке табличного вида только касание ячейки. не элемент внутри ячейки, как я могу выбрать день в календаре, а также свернуть ячейку при выделении. вот мой код установки.

    var selectedIndex   = IndexPath(row: 0, section: 0)
    extension TableVC: UITableViewDelegate {
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if selectedIndex == indexPath { return 350 }
        return 90
    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        selectedIndex = indexPath

        tableView.beginUpdates()
        tableView.reloadRows(at: [selectedIndex], with: .none)
        tableView.endUpdates()
    }
}

extension TableVC: UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return items.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: DailyTableViewCell.cellId, for: indexPath) as! DailyTableViewCell
        let item = items[indexPath.row]
        cell.configureCell(data: item)
        cell.subtitleLbl.text = getFormattedDate(date: Date(), format: "dd MMMM yyyy")
        cell.selectionStyle = .none
        return cell
    }
}

    // MARK: - JKCalendar Delegate
extension DailyTableViewCell: JKCalendarDelegate {
    func calendar(_ calendar: JKCalendar, didTouch day: JKDay) {
        selectedDate = day

        calendar.reloadData()
    }
}

// MARK: - JKCalendar DataSource
extension DailyTableViewCell: JKCalendarDataSource {
    func calendar(_ calendar: JKCalendar, marksWith month: JKMonth) -> [JKCalendarMark]? {
        if selectedDate == month {
            return [JKCalendarMark(type: .circle, day: selectedDate, color: .systemPink)]
        } else {
            return nil
        }
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...