问题
In my application i use Tapku calendar to display a date in calender.
I want to display particular date in calendar like,
I have date 2012-11-01 than Marker comes on 2012-11-01 in calender.
Please suggest me How can i do that with Tapku caleder.
回答1:
- (NSArray*) calendarMonthView:(TKCalendarMonthView*)monthView marksFromDate:(NSDate*)startDate toDate:(NSDate*)lastDate
{
[self generateRandomDataForStartDate:startDate endDate:lastDate];
return dataArray;
}
- (void) generateRandomDataForStartDate:(NSDate*)start endDate:(NSDate*)end{
// this function sets up dataArray & dataDictionary
// dataArray: has boolean markers for each day to pass to the calendar view (via the delegate function)
// dataDictionary: has items that are associated with date keys (for tableview)
NSLog(@"Delegate Range: %@ %@ %d",start,end,[start daysBetweenDate:end]);
self.dataArray = [NSMutableArray array];
self.dataDictionary = [NSMutableDictionary dictionary];
NSDate *d = start;
while(YES){
int r = arc4random();
if(r % 3==1){
[self.dataDictionary setObject:[NSArray arrayWithObjects:@"Item one",@"Item two",nil] forKey:d];
[self.dataArray addObject:[NSNumber numberWithBool:YES]];
}else if(r%4==1){
[self.dataDictionary setObject:[NSArray arrayWithObjects:@"Item one",nil] forKey:d];
[self.dataArray addObject:[NSNumber numberWithBool:YES]];
}else
[self.dataArray addObject:[NSNumber numberWithBool:NO]];
TKDateInformation info = [d dateInformationWithTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
info.day++;
d = [NSDate dateFromDateInformation:info timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
if([d compare:end]==NSOrderedDescending) break;
}
}
来源:https://stackoverflow.com/questions/12833841/how-to-set-marker-on-particular-date-in-tapku-calender