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 に答える