2017-08-04 85 views
0

嗨我想顯示JTAppleCalendar與當前選定的日期,但我希望它不會觸發isSelected,因爲我想顯示一個timepicker時,用戶實際上選擇一個日期當一個單元被選擇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 
    } 

} 

觸發器代碼

當日歷負載與當前日期

當前代碼的觸發0

@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

回答

0

這可以用下面的代碼來完成:

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

嗨,所以我改變了selectDates代碼,但validCell.isSelected仍然是真的,又觸發我timepicker推出。想法? –

+0

那麼如果'timePicker'的啓動取決於是否選擇了單元格,那麼您希望如何區分用戶選擇VS編程選擇? –

+0

嗯我不知道,是否有可能在日曆單元格頂部添加類似隱藏視圖的東西,或者會觸發timepicker的東西?我只是認爲有一種簡單的方法可以在選擇當前日期的情況下啓動日曆,然後在用戶選擇日期 –

相關問題