I want in this action whenever pause button is pressed it should pause the program execution as well because right now when i pause the audio file it still keeps on displaying views one after the other. I want that to be paused as well.
-(void)playpauseAction:(id)sender
{
if
([audioPlayer isPlaying]){
[sender setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateSelected];
[audioPlayer pause];
} else {
[sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
[audioPlayer play];
[self performSelector:@selector(displayviewsAction:) withObject:nil afterDelay:11.0];
}
}
Anyone know how i can pause the program execution as well.
You can use this
[NSThread sleepForTimeInterval:[[NSDate date] timeIntervalSince1970]];but you will not be able to resume it because your main thread sleeps so you will not receive the touch.
And I also think that your app will not be approved in store.
What I recommend is to use NSTimer to trigger the action and when you press pause just invalidate the timer, when you press play crate a new timer and fire it.