我有一个使用故事板的大型应用程序,其中包含许多转换。转换应该是从右到左,所以我做了一个自定义的 segue 来执行它。
当我使用常规转换时,我推入导航堆栈的每个视图控制器都会被保留,直到我弹出它。
虽然使用自定义 segues 不会保留前一个控制器(推动当前控制器的那个),并且当我弹回时,控制器的实例会获得不同的内存地址,这表明指针已更改。
这是自定义推送序列:
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition* transition = [CATransition animation];
transition.duration = .3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[sourceViewController.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
和自定义流行segue:
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition* transition = [CATransition animation];
transition.duration = .3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[sourceViewController.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
我用这种方法执行segue:
[self performSegueWithIdentifier:@"SearchToMenu" sender:self];
似乎没有任何效果,我还没有在网上找到任何东西。
如果我需要提供更多代码示例、截图等,请告诉我。