自定义搜索与CATransition不工作

时间:2013-07-22 17:02:47

标签: ios storyboard modal-dialog segue catransition

我正在尝试在viewControllers之间创建自定义转换。我正在关注this教程,但点击/点击按钮后没有任何反应!

这是CustomSegue.m

的代码
#import "CustomSegue.h"
#import "QuartzCore/QuartzCore.h"

@implementation CustomSegue

-(void)perform {
NSLog(@"ActionTest");

UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];

CATransition* transition = [CATransition animation];
transition.duration = .25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom



[sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
}

@end

记录日志但不执行转换,也不更改viewcontroller。 我也将segue风格改为“custom”,将类改为“ZHCustomSegue”

我错过了什么吗?

谢谢

1 个答案:

答案 0 :(得分:4)

将您的segue的最后两行更改为:

[destinationViewController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController presentViewController:destinationController animated:NO completion:nil]; 

您试图引用不存在的导航控制器。