iphone - 在没有导航 Controller 堆栈的情况下,以动画方式将 View Controller 从一个 View Controller 过渡到另一个 View Controller

标签 iphone objective-c ios

如何在没有导航 Controller 堆栈的情况下对 View Controller 从一个 View Controller 到另一个 View Controller 的过渡进行动画处理。 View Controller 仅由 UIToolbar 管理,因为它只有播放、倒带、停止、信息和选项按钮。我的代码如下所示,现在我有 23 个 View Controller ,它们一个接一个地加载,但在转换期间 UIToolbar 也与 View Controller 一起翻转,这是错误的。

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

我仍在寻找解决方案。将不胜感激帮助。

最佳答案

将它们全部插入

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

关于iphone - 在没有导航 Controller 堆栈的情况下,以动画方式将 View Controller 从一个 View Controller 过渡到另一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9235642/

相关文章:

iOS 7 如何使用 NSUserDefaults 保存一个 NSNumber?

objective-c - 区分实例和类

iOS NSPredicate 包含来自索引

ios - UINavigationBar 文本颜色在弹出后保持白色

ios - 居中 UILabel 不起作用?

iphone - Xcode:警告:输出文件的多个构建命令和错误:无法打开可执行文件 ''

iphone - 如何集成bitly api来缩短我在iphone sdk中的链接

iphone - 绘画应用中的 UISwipeGestureRecognizer

ios - 仅为目标 V​​iewController 设置导航栏

ios - Short 从字典中获取带有数组键的对象