有没有一种好方法可以在 View Controller 之间提供自定义转换?例如,在 iPad 上的“照片”应用中,点击相册会更改导航 Controller ,但它也会很好地融入照片网格中。
谢谢。
最佳答案
如果您所指的漂亮动画是照片网格从右侧滑入 View ,则由 UINavigationController 自动处理。您只需告诉它您想要显示哪个 View ,它就会为您处理幻灯片动画。
这将设置导航 Controller ,其中包含您的第一个 View (相册表格)。
// 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]];
然后创建第二个 View (照片网格)并要求导航 Controller 显示它。
// init your second view controller here
UIViewController *mySecondViewController;
[myNavController pushViewController:[mySecondViewController view] animated:YES];
[mySecondView release];
关于iphone - View Controller 之间的自定义转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2941222/