JZCalendarWeekView
JZCalendarWeekView copied to clipboard
Problems with refreshWeekView() after modify numOfDays
I have created a button that can control numofDays.
I pressed the button and ran that code.
reloadnumDay += 1
calendarWeekView.numOfDays = reloadNumDay
calendarWeekView.refreshWeekView()
But I did not get the result I wanted.
Initial Screen:
Result screen:
The screen I want:
It should start at 1 but start at 2 in the result screen.
I do not know why these results come out. Is there a workaround?
Hi, currently I didn't handle this requirement. Do you want to always keep the same day when you change the numOfDays
?
Yes. If i adding or subtracting numofDays, I want to keep the same day
What if it is 7 days with firstDayOfWeek
?
I always set it to Monday.
calendarWeekView.setupCalendar(numOfDays: numDay,
shopBookChargeList: self.shopBookChargeListString,
shopBookChargeEmplList: self.shopBookChargeEmplList,
setDate: Date.from(year: 2019, month: 05, day: 01) ?? Date(),
allEvents: AllDayBookModel(),
scrollType: .sectionScroll,
firstDayOfWeek: .Monday)
calendarWeekView.scrollableRange = (Date.from(year: 2019, month: 05, day: 01), Date.from(year: 2019, month: 05, day: shopBookChargeList.count))
calendarWeekView.updateFlowLayout(JZWeekViewFlowLayout(hourHeight: 80
, rowHeaderWidth: 50, columnHeaderHeight: 50, hourGridDivision: JZHourGridDivision.minutes_20))
Hi. I've fixed the problem by modifying your library.
I created a numofDaysReload
variable in JZBaseWeekView.swift and used it in the updateWeekView()
function.
JZBaseWeekView.swift :
public var numOfDays: Int!
public var numofDaysReload: Int = 1
...
open func refreshWeekView()
{
updateWeekView(to: self.initDate.add(component: .day, value: numOfDays + numofDaysReload))
}
In ViewController :
if numofDays += 1
{
calendarWeekView.numofDaysReload = -1
}
else if numofDays -= 1
{
calendarWeekView.numofDaysReload = 1
}
calendarWeekView.refreshWeekView()
I do not think it's an efficient method, but it's solved. I am a junior developer in Korea and have poor English and coding skills. Sorry for bothering you. If you see my reply, please close the issue.
Hi,
Thanks for doing it first. I am currently very busy. If I have time in the future and I might give you a better way to achieve this.
Thanks