JTAppleCalendar预选当前日期而不触发isSelected

时间:2017-08-04 13:19:25

标签: ios swift cell jtapplecalendar

您好我正在尝试使用当前日期显示JTAppleCalendar,但我希望它不会触发isSelected,因为我想在用户实际选择日期时显示时间戳,而不是在日历加载时触发与当前日期

选择单元格时的当前代码

func handleCellSelected(view: JTAppleCell?, cellState: CellState){
    guard let validCell = view as? CalendarCell else {return}
    if validCell.isSelected{
        validCell.selectedView.isHidden = false
        if remindMeOnDay.isOn{
            self.formatter.dateFormat = "yyyy MMMM dd"
            if userPickedDate{
                dateSelected.text = formatter.string(for:userDate)


                SelectTime(sender: validCell)

                //self.dateSelected.text = self.formatter.string(from: cellState.date)
                DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(300), execute: {
                    self.updateTableView(tableView: self.tableView)
                })
            }

        }

        userPickedDate = true

    }else {
        validCell.selectedView.isHidden = true
    }

 }

触发代码

@IBAction func remindMeOnDaySwitch(_ sender: UISwitch?) {
let date = Date()


    self.tableView.beginUpdates()
    tableView.reloadData()
    //Shows the calendar with current date selected
    if remindMeOnDay.isOn{
        calendarView.scrollToDate(date)
        self.calendarView.selectDates([NSDate() as Date])




        //self.calendarView.selectDates([NSDate() as Date])

        if !checkForNotificationAccess(){
            notificationAlert()
            remindMeOnDay.isOn = false
        }

    }
    if !remindMeOnDay.isOn {
        userDate = date
        userPickedDate = false
    }
    self.tableView.endUpdates()
}

The result I'm getting

1 个答案:

答案 0 :(得分:1)

可以使用以下代码完成此操作:

calendarView.selectDates([Date()], triggerSelectionDelegate: false)