0

我使用 KALViewcontroller API 在我的 iPhone 应用程序中显示日历。我想保存最后选择的日期,并在日历再次出现时将其显示为“突出显示”。目前它显示今天的日期。

KALViewController.m中,一个函数-(void)showAndSelectToday负责显示今天的日期并突出显示今天的图块。


[[self calendarView] selectTodayIfVisible];

//where *calendarView* is
- (KalView*)calendarView 
{ 
    checkDateConf = TRUE; 
    checkDate = FALSE; 
    return (KalView*)self.view; 
}

KalView.m 中


[gridView selectTodayIfVisible];

//其中gridView是KalGridView gridView;

KALGridView.m 中

声明了 selectTodayIfVisible


- (void)selectTodayIfVisible
{
  KalTileView *todayTile = [frontMonthView todaysTileIfVisible];
  if (todayTile)
    self.selectedTile = todayTile;
}

请指导我如何突出显示选定的日期。

4

1 回答 1

1

为了检测选择了哪个日期,我这样做了:

在 KalViewController 中查找 didSelectDate(委托方法)并添加通知帖子。

#pragma mark KalViewDelegate protocol

    - (void)didSelectDate:(KalDate *)date
    {
  //NSLog(@"DID select DATE:%@",date);
  self.selectedDate = [date NSDate];
  [[NSNotificationCenter defaultCenter] postNotificationName:@"DATA_SELECTED" object:[NSString stringWithFormat:@"%@",date]];
  NSDate *from = [[date NSDate] cc_dateByMovingToBeginningOfDay];
  NSDate *to = [[date NSDate] cc_dateByMovingToEndOfDay];
  [self clearTable];
  [dataSource loadItemsFromDate:from toDate:to];
  [tableView reloadData];
  [tableView flashScrollIndicators];
}

然后在您使用 Kal 的视图控制器中收到此帖子,就像:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userSelectDate:) name:@"DATA_SELECTED" object:nil];

调用的方法是:

-(void)userSelectDate:(NSNotification*)notification{
    NSLog(@"date selected:%@",[notification object]);
}
于 2012-11-28T09:23:34.893 回答