在没有导航控制器堆栈的情况下,将视图控制器从一个转换为另一个

时间:2012-02-10 22:21:58

标签: iphone objective-c ios

如何在没有导航控制器堆栈的情况下将视图控制器的Animate转换为另一个。 View Controller仅由UIToolbar管理,因为它只有播放,倒带,停止,信息和选项按钮。我的代码现在在下面给出我有23个视图控制器,它们一个接一个地加载但在转换期间UIToolbar也与视图控制器一起翻转是错误的。

-(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];
}

我仍在寻找解决方案。非常感谢帮助。

1 个答案:

答案 0 :(得分:1)

只需将它们全部推送

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];