我试图做到这一点,以便当我在 xib 文件中设置的工具栏中的 UIButton 被按下时,一个新的 Controller 会加载到 View 中。
我该如何实现呢?我尝试过复制 FlipViewController,但我认为您不能拥有多个这样的 Controller 。
最佳答案
- iPad(不要在整个屏幕上使用 UINavigationController)。
你可以用一个漂亮的动画进行切换,如下所示:
(仅适用于应用程序委托(delegate),除非您更改用 //仅适用于应用程序委托(delegate)注释的行
。
UIViewController *ctrl = [[UIViewController alloc] initWithNibName:@"someXIBStuff" bundle:nil];
CAKeyframeAnimation *theAnimation = [CAKeyframeAnimation animation];
theAnimation.values = [NSArray arrayWithObjects:
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.12,1.12,1)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1,1,1)],
nil];
theAnimation.cumulative = YES;
theAnimation.duration = 0.3;
theAnimation.repeatCount = 0;
theAnimation.removedOnCompletion = YES;
theAnimation.timingFunctions = [NSArray arrayWithObjects:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn],
nil
];
[self.window.layer addAnimation:theAnimation forKey:@"transform"];
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
transition.delegate = self;
[self.window.layer addAnimation:transition forKey:nil];
self.window.rootViewController = ctrl; // works only in app delegate
[ctrl release];
- iPhone: 使用 UINavigationController (如果可能的话)。如果没有,您可以使用上面的示例。
关于objective-c - 如何将界面中的按下按钮与转移到另一个 View 关联起来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10129788/