Question

I noticed that Tapku calendar grid resized between 5x5 and 6x6 depending on the month's dates distribution. For example it displays 5x5 grid for March 2012 and displays 6x6 grid for September 2012! For me it makes GUI alignments go wrong so I want grid to be always 6x6. I have been looking into TKCalenderMonthView's rangeOfDatesInMonthGrid method but not getting how it creates the grid! Could anyone please tell me how to fix the grid 6x6 always.

Thanks.

Was it helpful?

Solution

Solution to 2nd Point.If you want to display a mark on selected and remove mark from deselected dates then use follwoing code.(It wont display blue mark)

- (void)calendarMonthView:(TKCalendarMonthView *)monthView didSelectDate:(NSDate *)d {
NSLog(@"calendarMonthView didSelectDate");

NSDateFormatter *df=[[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd"];
[df setTimeZone:[NSTimeZone systemTimeZone]];

NSString *strqw=[df stringFromDate:d];
NSLog(@"%@",strqw);
NSString *stss=[strqw stringByAppendingString:@" 00:00:00 +0000"];
NSLog(@"%@",stss);
int k=0;
for (int i=0; i<[array1 count]; i++) {
    if([[array1 objectAtIndex:i]isEqualToString:stss]){
         [array1 removeObjectAtIndex:i];
        k=1;
    }
}
if(k==0)
[array1 addObject:stss];

[calendar reload];
}

And add this line
NSArray *data=[[NSArray alloc] initWithArray:array1]; in the below method

 - (NSArray*)calendarMonthView:(TKCalendarMonthView *)monthView marksFromDate:(NSDate *)startDate toDate:(NSDate *)lastDate

OTHER TIPS

Here's a little hack I use:

In the viewDidAppear I have

[calendar selectDate:[NSDate dateWithTimeIntervalSinceNow:-31*24*60*60]];
[calendar selectDate:[NSDate dateWithTimeIntervalSinceNow:0]];

And in the

- (void) calendarMonthView:(TKCalendarMonthView*)monthView monthDidChange:(NSDate*)month animated:(BOOL)animated{

I just check the height of my calendar and do whatever I need to do. This is done because if you check the height of the frame immediately after instantiation of the calendar, it will return the normal 5*7 height instead of the 6*7.

Hope that helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top