0

我在我的 iOS 应用程序中使用 TAPKU 日历。在tapku日历中加载完整数据后,我想在日期磁贴上添加更多标记。

我从异步进程中获得了一些额外的数据,我想在日历上也标记这些数据。

我怎样才能做到这一点。提前致谢。

4

1 回答 1

0

这确实是可能的,以日历视图为例,将 _refreshDataPageWithAtIndex 修改为如下所示:

- (void) _refreshDataWithPageAtIndex:(NSInteger)index{

    UIScrollView *sv = self.pages[index];
    TKTimelineView *timeline = [self _timelineAtIndex:index];


    CGRect r = CGRectInset(self.horizontalScrollView.bounds, HORIZONTAL_PAD, 0);
    r.origin.x = self.horizontalScrollView.frame.size.width * index + HORIZONTAL_PAD;
    sv.frame = r;



    timeline.startY = VERTICAL_INSET;

    for (UIView* view in sv.subviews) {
        if ([view isKindOfClass:[TKCalendarDayEventView class]]){
            [self.eventGraveYard addObject:view];
            [view removeFromSuperview];
        }
    }

    if(self.nowLineView.superview == sv) [self.nowLineView removeFromSuperview];
    if([timeline.date isTodayWithTimeZone:self.timeZone]){

        NSDate *date = [NSDate date];
        NSDateComponents *comp = [date dateComponentsWithTimeZone:self.timeZone];

        NSInteger hourStart = comp.hour;
        CGFloat hourStartPosition = hourStart * VERTICAL_DIFF + VERTICAL_INSET;

        NSInteger minuteStart = round(comp.minute / 5.0) * 5;
        CGFloat minuteStartPosition = roundf((CGFloat)minuteStart / 60.0f * VERTICAL_DIFF);

        CGRect eventFrame = CGRectMake(self.nowLineView.frame.origin.x, hourStartPosition + minuteStartPosition - 5, NOB_SIZE + self.frame.size.width - LEFT_INSET, NOB_SIZE);
        self.nowLineView.frame = eventFrame;
        [sv addSubview:self.nowLineView];

    }

    if(!self.dataSource) return;

    timeline.events = [NSMutableArray new];
    [self.dataSource calendarDayTimelineView:self eventsForDate:timeline.date andEvents:timeline.events success:^{
        [timeline.events sortUsingComparator:^NSComparisonResult(TKCalendarDayEventView *obj1, TKCalendarDayEventView *obj2){
            return [obj1.startDate compare:obj2.startDate];
        }];

        [self _realignEventsAtIndex:index];
        if(self.nowLineView.superview == sv)
            [sv bringSubviewToFront:self.nowLineView];
    }];
}

然后将您的 eventsForDate 函数更改为如下所示:

- (void) calendarDayTimelineView:(TKCalendarDayView*)calendarDayTimeline eventsForDate:(NSDate *)eventDate andEvents:(NSMutableArray *)events success:(void (^)())success {

    [Model doSomethingAsync andSuccess:^(NSArray *classes) {

        // .. Add stuff to events..

        success();
    }];
}

我假设其他控件的模式非常相似。前提是您正在等待继续格式化/布局流程,直到获得数据。

于 2013-10-09T02:37:50.347 回答