CATransition 到其他视图有效,但转换回来时崩溃
我正在使用此代码从当前视图转换到另一个视图,并且它有效。问题是,当我尝试返回当前视图时,应用程序崩溃了。
这是我用来从当前视图传递到新视图的代码:
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
// using the ease in/out timing function
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromRight;
transition.delegate = self;
// Next add it to the containerView's layer. This will perform the transition based on how we change its contents.
[self.view.layer addAnimation:transition forKey:nil];
// Here we hide view1, and show view2, which will cause Core Animation to animate view1 away and view2 in.
self.view.hidden = YES;
MyMessages *info1=[[MyMessages alloc] initWithNibName:@"MyMessages" bundle:nil];
[self.view addSubview:info1.view];
info1.view.hidden = NO;
self.view.hidden = NO;
我尝试使用以下代码返回:
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
// using the ease in/out timing function
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromLeft;
transition.delegate = self;
// Next add it to the containerView's layer. This will perform the transition based on how we change its contents.
[self.view.layer addAnimation:transition forKey:nil];
// Here we hide view1, and show view2, which will cause Core Animation to animate view1 away and view2 in.
self.view.hidden = YES;
FirstViewController *info1=[[ FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
[self.view addSubview:info1.view];
info1.view.hidden = NO;
self.view.hidden = NO;
I am using this code to transition from the current view to another and it works. The problem is that when I try to return to the current view the app crashes.
This is the code I use to pass from the current view to the new one:
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
// using the ease in/out timing function
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromRight;
transition.delegate = self;
// Next add it to the containerView's layer. This will perform the transition based on how we change its contents.
[self.view.layer addAnimation:transition forKey:nil];
// Here we hide view1, and show view2, which will cause Core Animation to animate view1 away and view2 in.
self.view.hidden = YES;
MyMessages *info1=[[MyMessages alloc] initWithNibName:@"MyMessages" bundle:nil];
[self.view addSubview:info1.view];
info1.view.hidden = NO;
self.view.hidden = NO;
I try to return using this code:
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
// using the ease in/out timing function
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromLeft;
transition.delegate = self;
// Next add it to the containerView's layer. This will perform the transition based on how we change its contents.
[self.view.layer addAnimation:transition forKey:nil];
// Here we hide view1, and show view2, which will cause Core Animation to animate view1 away and view2 in.
self.view.hidden = YES;
FirstViewController *info1=[[ FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
[self.view addSubview:info1.view];
info1.view.hidden = NO;
self.view.hidden = NO;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是在
UITabBarController
的UIView
和新UIView
之间进行转换所需的代码。该代码转到按钮的IBAction
,该按钮存在于UITabBarController
的UIView
之一中。谢谢你的帮助!为了实现这一目标,我已经尝试了一天多了。我希望它能帮助有同样问题的人。
This is the code that needed to make the transition between an
UIView
of aUITabBarController
and a newUIView
. The code goes to a button'sIBAction
which exists in one of theUIView
s of theUITabBarController
.Thanks for you help! I have been trying this for more than a day to achieve it. I hope it will help someone with the same problem.