0

在我的应用程序中,我使用 Tapku 日历在日历中显示日期。

我想在日历中显示特定日期,例如,

我的日期是 2012-11-01,而 Marker 在日历中的日期是 2012-11-01。

请建议我如何使用 Tapku caleder 做到这一点。

4

1 回答 1

0
     - (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;
    }

}
于 2012-10-11T07:09:17.387 回答