Adding and decreasing time with UIButton to Timer
2 answers
-(void)viewDidLoad{
UIButton *buttonPlus = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIButton *buttonMinus = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[buttonPlus addTarget:self action:@selector(addTime) forControlEvents:UIControlEventTouchUpInside];
[buttonMinus addTarget:self action:@selector(removeTime) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:buttonMinus];
[self.view addSubview:buttonPlus];
}
-(void) addTime {
[yourTimer setFireDate:[[yourTimer fireDate] dateByAddingTimeInterval:secondsToAdd]];
}
-(void) removeTime {
[yourTimer setFireDate:[[yourTimer fireDate] dateByAddingTimeInterval:-secondsToAdd]];
}
+2
source to share