2015-12-29 21 views
0

我正在使用DSLCalendarView來顯示計劃。當月份發生變化時,didChangeToVisibleMonth被調用。我正在更新此事件的數據。但我也希望日曆在此事件中重新加載。 是否可以刷新/重新加載DSLCalendarViewDSLCalendarView刷新

回答

1

在DSLCalendarView.m,您將添加標籤兩種觀點的價值。下面添加標籤值的代碼。只是在文件中改變。

- (id)initWithFrame:(CGRect)frame { 
self = [super initWithFrame:frame]; 
if (self != nil) { 
    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(reloadCalendar:) 
               name:@"reloadCalendar" 
               object:nil]; 

    [self commonInit]; 
} 

return self;} 

-(void)reloadCalendar{ 
    [self commonInit]; 
} 

- (void)commonInit { 
[[self viewWithTag:508] removeFromSuperview]; 
[[self viewWithTag:509] removeFromSuperview]; 
self.monthSelectorView.tag=508; 
self.monthContainerView.tag=509; 
} 

- (void)didTapMonthBack:(id)sender { 
NSDateComponents *newMonth = self.visibleMonth; 
newMonth.month--; 
[self commonInit]; 
[self setVisibleMonth:newMonth animated:YES]; } 

- (void)didTapMonthForward:(id)sender { 
NSDateComponents *newMonth = self.visibleMonth; 
newMonth.month++; 
[self commonInit]; 
[self setVisibleMonth:newMonth animated:YES];} 

如果我們將點擊前進或後退按鈕,在日曆後重新加載日曆。

在視圖控制器如果我們改變的話只是一個通知調用方法時間方法會調用事件調用。

- (void)calendarView:(DSLCalendarView *)calendarView didChangeToVisibleMonth:(NSDateComponents *)month { 

[[NSNotificationCenter defaultCenter]postNotificationName:@"reloadCalendar" object:self]; 
NSLog(@"Now showing %@", month); 

}

+0

工作就像一個魅力。謝謝。 – Nitish

+0

你總是歡迎@Nitish –

0

看見了圖書館不要有任何把戲做到這一點,遺憾的是不具有重載方法:(。可能有些變通解決問題,你的情況。