Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented UIApplicationSignificantTimeChangeNotification #120

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion FSCalendar/FSCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ @interface FSCalendar ()<UICollectionViewDataSource, UICollectionViewDelegate, U
@property (readonly, nonatomic) id<FSCalendarDelegateAppearance> delegateAppearance;

- (void)orientationDidChange:(NSNotification *)notification;
- (void)significantTimeChange:(NSNotification *)notification;

- (NSDate *)dateForIndexPath:(NSIndexPath *)indexPath;
- (NSIndexPath *)indexPathForDate:(NSDate *)date;
Expand Down Expand Up @@ -215,12 +216,13 @@ - (void)initialize
[self invalidateLayout];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(significantTimeChange:) name:UIApplicationSignificantTimeChangeNotification object:nil];
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationSignificantTimeChangeNotification object:nil];
}

#pragma mark - Overriden methods
Expand Down Expand Up @@ -678,6 +680,12 @@ - (void)orientationDidChange:(NSNotification *)notification
[_collectionViewLayout invalidateLayout]; // Necessary in Swift. Anyone can tell why?
}

- (void)significantTimeChange:(NSNotification *)notification
{
[self setToday:[NSDate date].fs_dateByIgnoringTimeComponents];
[self reloadData];
}

#pragma mark - Properties

- (void)setAppearance:(FSCalendarAppearance *)appearance
Expand Down