This question is locked. New answers and comments are not allowed.
I have a tableView that uses a TKCalendar as the headerView and when the screen is rotated the Calendar switches from a Month View to Week View. The issue I'm having is that in the Week Mode I can scroll forward all I want, but can't scroll back to any date before the current date, but when I rotate the device back to switch into Month mode I can navigate forwards and backwards without any issues. Don't know what code to show so here's a few snippets.
Here's the setup of the calendar in viewDidLoad
self.calendarView.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]self.calendarView.dataSource = selfself.calendarView.delegate = selfself.calendarView.allowPinchZoom = falseself.calendarView.selectionMode = TKCalendarSelectionMode.Singleself.calendarView.viewMode = calendarViewModeself.updateCalendarPresenter()//set the minimum and maximum date componentslet dateComponents = NSDateComponents()dateComponents.year = -5self.calendarMinDate = NSCalendar.currentCalendar().dateByAddingComponents(dateComponents, toDate: NSDate(), options: [])!dateComponents.year = 5self.calendarMaxDate = NSCalendar.currentCalendar().dateByAddingComponents(dateComponents, toDate: NSDate(), options: [])!self.calendarView.minDate = self.calendarMinDateself.calendarView.maxDate = self.calendarMaxDate
This is what I have in the rotate interface function
override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) { //landscape mode should switch to week mode self.calendarView.viewMode = TKCalendarViewMode.Month if UIDevice.currentDevice().orientation.isLandscape { self.calendarView.viewMode = TKCalendarViewMode.Week } self.updateCalendarPresenter() //navigate to the current selected date as well self.calendarView.navigateToDate(self.selectedDate, animated: false) //make sure the table layout is updated self.mainTable.setNeedsLayout() self.mainTable.layoutIfNeeded() }
This is the updatePresenter that is called when the device is rotated as well
func updateCalendarPresenter() { var presenter = TKCalendarMonthPresenter() if self.calendarView.viewMode == TKCalendarViewMode.Week { presenter = self.calendarView.presenter as! TKCalendarWeekPresenter } //the month presenter needs an additional item added else { presenter = self.calendarView.presenter as! TKCalendarMonthPresenter presenter.equalWeekNumber = false } //hide the title view presenter.titleHidden = true //change the background color of the calendar presenter.style.backgroundColor = UIColor(hexString: ColorCodes.calendarBackground) //update case of cell presenter.style.dayNameTextEffect = TKCalendarTextEffect.Uppercase //let the header stay as a sticky row presenter.headerIsSticky = true //update presenter presenter.update(true) }