我有一个UINavigationController有一个可见的导航栏和工具栏。当推动一个控制器(同一个控制器)时,我只想动画内容部分(例如滑动效果),并保持NavigationBar和Toolbar不动画/常量。任何人都可以提供任何建议干净的方式做到这一点?谢谢。UINavigationController自定义过渡动画
2
A
回答
1
我手动移动的看法和使用动画块它们的动画:
// Get position of old view controller
CGPoint center = [oldViewController.view center];
// Position new view controller to the right of old one
[newViewController.view setCenter:CGPointMake(center.x + 320, center.y)];
// Animate change
[UIView beginAnimations:@"myAnimation" context:NULL];
// Move old view off screen
[oldViewController.view setCenter:CGPointMake(center.x - 320, center.y)];
// Move new view onto screen
[newViewController.view setCenter:center];
// Set animation delegate to self so that we can detect when animation is complete
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationComplete:finished:target:)];
// Finish animation block
[UIView commitAnimations];
如果您需要使用您需要导航控制器实际推新的ViewController确保您的动画之后做到这一点已完成,否则旧视图将不会显示。为此,您需要使用setAnimationDelegate方法来获取动画完成时间和传入选择器方法的通知。在同一类中实现上述代码和以下方法:
(void)animationComplete:(NSString *)animationId
finished:(BOOL)finished
target:(UIView *)target
{
if([animationId isEqualToString:@"myAnimation"])
{
// Push viewcontroller here
}
}
1
尝试将工具栏作为子视图添加到窗口而不是视图。并限制导航控制器的视图高度,以便它可以看到你的工具栏。现在,如果您推动视图控制器,则导航栏和工具栏将保持无生气/停滞状态。
0
将新UIViewController的navigationItem设置为与当前UIViewController相同。
newViewcontroller.navigationItem = self.navigationItem;
[self.navigationController pushViewController:recallViewController animated:YES];
相关问题
- 1. UINavigationController的自定义过渡动画视图控制器alpha值
- 2. 自定义的UINavigationController动画
- 3. 自定义UINavigationController动画:CATransition
- 4. Android的自定义动画过渡
- 5. 自定义segue过渡动画
- 6. 自定义UIViewController动画没有UINAVIGATIONCONTROLLER
- 7. iPhone - UINavigationController - 自定义动画与CATransaction
- 8. 两个活动之间的自定义过渡(动画)Android
- 9. 在Android中用于过渡的自定义动画对象?
- 10. 使用CATransition自定义视图 - 控制过渡动画
- 11. CSS过渡动画
- 12. 自定义UINavigationController
- 13. 防止UINavigationController的过渡与在IOS 11向上偏移动画?
- 14. UINavigationController自定义动画防止从工作中滑动回去
- 15. UINavigationController自定义titleView
- 16. 自定义UINavigationController UINavigationBar
- 17. UINavigationController上的自定义titleView动画不正确
- 18. 过渡动画,高cpu?
- 19. IinnerHTML过渡/动画CSS
- 20. 查看过渡动画
- 21. UIView过渡和动画
- 22. Android的动画过渡
- 23. CSS切换过渡动画
- 24. UINavigation /的TabBar过渡动画
- 25. 流行了过渡动画
- 26. 平滑(动画)GUI过渡
- 27. Angular.js:查看过渡动画
- 28. iPhone:动画过渡类型?
- 29. jQuery CSS过渡动画
- 30. 一个过渡动画
Thx。它几乎可以工作,除了oldViewController视图在被推入后消失。当动画发生时,旧视图只是一种黑色。你知道如何在推送之后保持oldViewController.view可见吗?这是我添加来设置oldViewController和newViewController的代码。 \t CGPoint center = [self.view center]; \t UIViewController * oldViewController = [self.navigationController topViewController]; NewController * newViewController = [[[NewController alloc] init] autorelease]; [self.navigationController pushViewController:newViewController animated:NO]; – JStay 2010-02-25 02:11:38
在推入新视图控制器之前,您需要结束动画块。也就是说,在[self.navigationController pushViewController:newViewController animated:NO]之前调用[UIView commitAnimations] – pheelicks 2010-02-25 09:09:53
感谢您的回应。在提交之后,我将push移动到了,并且它仍然产生与新视图转换为黑/空视图相同的结果。我在没有推送的情况下尝试了代码,看看旧视图是否转换出来,并且它可以工作,但是一旦我介绍推送,它就会消失。 – JStay 2010-02-25 09:54:28