我正在使用DSLCalendarView来显示时间表。当月份发生变化时,将调用didChangeToVisibleMonth。我正在更新有关这一事件的数据。但是我希望日历也能在这次活动中重新加载。是否可以刷新/重新加载DSLCalendarView?
发布于 2016-01-05 13:52:20
在DSLCalportView.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);}
发布于 2016-01-05 10:10:28
我看到库没有任何技巧去做,不幸的是没有重新加载方法:可能是为了解决你的问题而做的一些工作。
https://stackoverflow.com/questions/34510714
复制相似问题