gpt4 book ai didi

ios - 在关闭 NavigationViewController 之前,CATransition 在方向更改时出错

转载 作者:技术小花猫 更新时间:2023-10-29 10:54:10 27 4
gpt4 key购买 nike

这是我用来呈现 navigationViewController 的代码:

-(IBAction)showFilterView:(id)sender {

FilterViewController *vc=[self.storyboard instantiateViewControllerWithIdentifier:@"FilterViewController"];
UINavigationController *nvc=[[UINavigationController alloc] initWithRootViewController:vc];


CATransition *transition = [CATransition animation];
transition.duration = 0.35;
transition.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromLeft;

UIView *containerView = self.view.window;
[containerView.layer addAnimation:transition forKey:nil];
[self.tabBarController presentViewController:nvc animated:NO completion:nil];

}

这是我要解雇的代码

-(IBAction)back:(id)sender {


CATransition *transition = [CATransition animation];
transition.duration = 0.35;
transition.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromRight;
UIView *containerView = self.view.window;
[containerView.layer addAnimation:transition forKey:nil];
[[self.navigationController presentingViewController] dismissViewControllerAnimated:NO completion:nil];
}

情况 1 --- 在横向模式下运行良好

情况 2 --- 在纵向模式下运行良好

情况 3 --- 以纵向模式呈现并以横向模式关闭无法正常工作(显示正确 View 之前的额外动画)

情况 4 --- 以横向模式呈现并以纵向模式关闭无法正常工作(显示正确 View 之前的额外动画)

最佳答案

UIWindow 层具有奇怪的旋转属性,您执行的任何动画都不能保证正确检测方向(并且因不同的 iOS 版本而异)。做你想做的最简单的方法是使用自定义演示动画。 This is a good writeup如何去做。

关于ios - 在关闭 NavigationViewController 之前,CATransition 在方向更改时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31161838/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com