ios - DSLCalendarView 重新加载

标签 ios iphone

我正在使用 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/

相关文章:

php - 在浏览器中获取 json 结果,但在 iOS 模拟器中不行

android - iOS 的相关概念,例如 "APK Expansion Files in Android"

iphone - 动态改变UITextView高度而不是滚动

iphone - 单击 "back"按钮时 UINavigationController 应用程序崩溃

ios - 在 iOS 上使用 Core Graphics 将 PDF 渲染为图像的颜色准确性问题

iphone - 如何让 UITableViewCell 的 subview 扩展到单元格的边界之外

iphone - 调用另一个类中的方法失败

ios - 不同屏幕的图像尺寸

android - 如何使用phonegap扫描条码

iOS 设备 token 和推送通知 Ionic