iOS: Make Tapku calendar library tiles grid size to 6x6 always

橙三吉。 提交于 2019-12-10 12:04:40

问题


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.


回答1:


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



回答2:


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!



来源:https://stackoverflow.com/questions/9719633/ios-make-tapku-calendar-library-tiles-grid-size-to-6x6-always

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!