4

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

这是 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

日志被记录,但没有执行转换,视图控制器也没有改变。我还将 segue 样式更改为“custom”,将 class 更改为“ZHCustomSegue”

我错过了什么吗?

谢谢

4

1 回答 1

4

将 segue 的最后两行更改为:

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

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

于 2013-07-22T18:30:27.383 回答