I don’t know how to code this but i want program to skip or jump this statement from executing
self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
target:self
selector:@selector(displayviewsAction:)
userInfo:nil
repeats:NO];
when pause is pressed to resume play.
Reason i want this cause in play/pause button everything is good except when pause is pressed to resume it starts reloading view controllers by executing this statement from the below code
self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
target:self
selector:@selector(displayviewsAction:)
userInfo:nil
repeats:NO];
I have tried so many different ways to solve this issues but nothing is working out.
if([audioPlayer isPlaying]){
[sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateSelected];
[audioPlayer pause];
[self pauseTimer];
}else {
[sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
[audioPlayer play];
[self resumeTimer];
self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
target:self
selector:@selector(displayviewsAction:)
userInfo:nil
repeats:NO];
That’s how loading view controllers one after other
- (void)displayviewsAction:(id)sender
{
First *firstController = [[First alloc] init];
firstController.view.frame = CGRectMake(0, 0, 320, 480);
CATransition *transitionAnimation = [CATransition animation];
[transitionAnimation setDuration:1];
[transitionAnimation setType:kCATransitionFade];
[transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[self.view.layer addAnimation:transitionAnimation forKey:kCATransitionFade];
[self.view addSubview:firstController.view];
[self.view addSubview:toolbar];
[firstController release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(Second) userInfo:nil repeats:NO];
}
-(void)Second
{
Second *secondController = [[Second alloc] init];
secondController.view.frame = CGRectMake(0, 0, 320, 480);
CATransition *transitionAnimation = [CATransition animation];
[transitionAnimation setDuration:1];
[transitionAnimation setType:kCATransitionReveal];
[transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[self.view.layer addAnimation:transitionAnimation forKey:kCATransitionReveal];
[self.view addSubview:secondController.view];
[self.view addSubview:toolbar];
[secondController release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:27 target:self selector:@selector(Third) userInfo:nil repeats:NO];
}
This is my last attempt to see if i can find some solution for this issue. I have spent two weeks on this issue but no success.
If someone can solve my this issue.
Thanks so much for help.
I found one little bit complex solution.
In you
.hfile create aBOOL isFirstTime; int methodSelector;.In your implementation file:
and change your code like this:
set the
methodSelectorin your view changing methods accordingly. InSecondmethod set it as 2 inThirdset it as 3 and so on.methodSelectoris used for calling the method after pausing.