2012-06-13 20 views
0

我已經使用KALViewcontroller API在我的iPhone應用程序中顯示日曆。我想保存上次選擇的日期,並在日曆再次出現時將其顯示爲「突出顯示」。 當前顯示今天的日期。iPhone sdk-保存上次在KALViewController中選擇的日期

KALViewController.m功能- (無效)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; 
} 

請指導我如何將突出選定的日期。

回答

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]; 
} 
在使用卡爾收到此訊息的視圖控制器

然後就像:

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

和調用的方法是:

-(void)userSelectDate:(NSNotification*)notification{ 
    NSLog(@"date selected:%@",[notification object]); 
} 
相關問題