简体   繁体   English

视图控制器之间的自定义过渡?

[英]Custom transitions between view controllers?

Is there a good way to provide custom transitions between view controllers? 有没有一种好的方法可以在视图控制器之间提供自定义过渡? For example, in the Photos app on the iPad, tapping on a photo album changes the navigation controller, but it also animates nicely into the grid of photos. 例如,在iPad上的“照片”应用程序中,点击相册可以更改导航控制器,但它也可以将动画很好地呈现到照片网格中。

Thanks. 谢谢。

If the nice animation you're referring to is the photo grid sliding into view from the right, that's handled by the UINavigationController automatically. 如果您要指的是精美的动画,则是从右侧滑入视图的照片网格,则由UINavigationController自动处理。 You just tell it which view you want to show and it will handle the slide animation for you. 您只需告诉它要显示的视图,它将为您处理幻灯片动画。

This sets up the navigation controller with your first view (the photo album table) on it. 这将在导航控制器上设置您的第一个视图(相册表)。

// init your first view controller here, create a navigation controller for it
UIViewController *myRootViewController;
UINavigationController *myNavController;
myNavController = [[UINavigationController alloc]
                   initWithRootViewController:[myRootViewController view]];
// the nav controller now owns your first view
[myRootView release];
// add the nav controller view (ie. do this in the app delegate)
[window addSubView:[myNavController view]];

Then create the second view (the photo grid) and ask the navigation controller to display it. 然后创建第二个视图(照片网格),并要求导航控制器显示它。

// init your second view controller here
UIViewController *mySecondViewController;
[myNavController pushViewController:[mySecondViewController view] animated:YES];
[mySecondView release];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM