Search code examples
iosobjective-csdktapku

IOS: Tapku calendar: starting week on Sunday, or not, depending on user choice


I am using tapku calendar in my project. I need to make an option for the user to start week on Sunday or on Monday. There is a method in viewDidLoad:

(id)initWithSunday:(BOOL)sundayFirst

Is there a way to update the calendar with new option? I tried calling initWithSunday with new value and [calendar reload], but errors occurred.


Solution

  • Figured it out. The calendar subview must be removed from superview, set to nil, and added again.

    [calendar removeFromSuperview]; 
    calendar= nil; 
    
    calendar =  [[TKCalendarMonthView alloc] initWithSundayAsFirst:startWhithSunday];
    calendar.delegate = self;
    calendar.dataSource = self;
    calendar.frame = CGRectMake(14, 11, calendar.frame.size.width, calendar.frame.size.height);
    [self.view addSubview:calendar];
    [calendar reload];