Skip to content

Commit

Permalink
Setup TKCurrentTimeLabel to correctly update time when its added to a…
Browse files Browse the repository at this point in the history
… view.
  • Loading branch information
devinross committed Feb 23, 2015
1 parent eaaf8c2 commit 62e434d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/TapkuLibrary/TKCurrentTimeLabel.m
Expand Up @@ -47,6 +47,16 @@ - (instancetype) initWithFrame:(CGRect)frame {
return self;
}

- (void) willMoveToWindow:(UIWindow *)newWindow{
if(newWindow==nil){
[self.timer invalidate];
self.timer = nil;
return;
}
[self _updateTime];
[self _startTimer];
}

- (void) _updateTime{
self.attributedText = [self attributeStringWithTime:[self currentTime]];
}
Expand All @@ -63,7 +73,8 @@ - (void) handleEnteredBackground:(id)sender{
}
- (void) handleEnteredForeground:(id)sender{
[self _updateTime];
[self _startTimer];
if(self.window)
[self _startTimer];
}

#pragma mark Functions for Subclassing
Expand Down

0 comments on commit 62e434d

Please sign in to comment.