我正在使用 DSLCalendarView
来显示日程安排。当月份改变时,didChangeToVisibleMonth
被调用。我正在更新有关此事件的数据。但我也希望在这次事件中重新加载日历。
是否可以刷新/重新加载 DSLCalendarView
?
最佳答案
在 DSLCalendarView.m 中,您将为两个 View 添加标签值。下面添加标签值代码。只需更改文件即可。
- (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];}
如果我们在重新加载日历后单击日历中的前进或后退按钮。
在 View Controller 中,如果我们在方法调用时更改事件调用,则只有一个通知调用方法。
- (void)calendarView:(DSLCalendarView *)calendarView didChangeToVisibleMonth:(NSDateComponents *)month {
[[NSNotificationCenter defaultCenter]postNotificationName:@"reloadCalendar" object:self];
NSLog(@"Now showing %@", month);
关于ios - DSLCalendarView 重新加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34510714/