user1120133
user1120133

Reputation: 3234

Animate transition of view controllers from one to another without navigation controller stack

How i can Animate transition of view controllers from one to another without navigation controller stack. View Controller is managed only by UIToolbar because it has only play, rewind, stop, info and option buttons. My code is given below right now i have is 23 view controllers which are loading one after the other but during transition UIToolbar is also flipping along with the view controllers which is wrong.

-(void)playAction:(id)sender
{
[audioPlayer play];
[self performSelector:@selector(displayviewsAction:) withObject:nil afterDelay:11.0];
}

- (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:kCATransitionFade];
[transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[self.view.layer addAnimation:transitionAnimation forKey:kCATransitionFade];
[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];
}

-(void)Third {
Third *thirdController = [[Third alloc] init];
thirdController.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:thirdController.view];
[self.view addSubview:toolbar];
[thirdController release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(Fourth) userInfo:nil repeats:NO];
}

-(void)Fourth {
Fourth *fourthController = [[Fourth alloc] init];
fourthController.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:fourthController.view];
[self.view addSubview:toolbar];
[fourthController release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:25 target:self selector:@selector(Fifth) userInfo:nil repeats:NO];
}

I am still looking for solution. Will appreciate help.

Upvotes: 0

Views: 673

Answers (1)

NeverBe
NeverBe

Reputation: 5037

just push them all

NSMutableArray *controllers = [NSMutableArray arrayWithArray:[self.navigationController viewControllers]];
[controllers addObject:vc1];
[controllers addObject:vc2];
[controllers addObject:vc3];
[controllers addObject:vc4];
[self.navigationController setViewControllers:controllers animated:YES];

Upvotes: 1

Related Questions