Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a boolean value to check if clock is started or not. If already s…

…tarted and start method called -> Not Restart Clock Animation
  • Loading branch information...
commit dd480ea5345cdff834de8d22dceeb1385ea10607 1 parent fd2244e
Rousseau Quentin authored
View
1  AnalogClockWithImages/PSAnalogClockView.h
@@ -22,6 +22,7 @@ typedef enum {
@interface PSAnalogClockView : UIView
+@property (nonatomic) BOOL isStarted;
@property (nonatomic, strong) UIImage *secondHandImage;
@property (nonatomic, strong) UIImage *minuteHandImage;
@property (nonatomic, strong) UIImage *hourHandImage;
View
17 AnalogClockWithImages/PSAnalogClockView.m
@@ -99,17 +99,22 @@ - (void)addImageViews
- (void)start
{
- self.clockUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
- target:self
- selector:@selector(updateClockTimeAnimated:)
- userInfo:nil
- repeats:YES];
- [self updateClockTimeAnimated:NO];
+ if(!isStarted)
+ {
+ self.clockUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
+ target:self
+ selector:@selector(updateClockTimeAnimated:)
+ userInfo:nil
+ repeats:YES];
+ [self updateClockTimeAnimated:NO];
+ isStarted = YES;
+ }
}
- (void)stop
{
[self.clockUpdateTimer invalidate]; self.clockUpdateTimer = nil;
+ isStarted = NO;
}
- (void)updateClockTimeAnimated:(BOOL)animated
Please sign in to comment.
Something went wrong with that request. Please try again.