我正在使用此代码从当前视图转换到另一个并且它可以正常工作。问题是,当我尝试返回当前视图时,应用程序崩溃。
这是我用来从当前视图传递到新视图的代码:
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;
答案 0 :(得分:0)
这是在UIView
UITabBarController
和新UIView
之间进行转换所需的代码。代码转到IBAction
的{{1}}之一的按钮UIView
。
UITabBarController
谢谢你的帮助!我已经尝试了一天以上来实现它。我希望它可以帮助有同样问题的人。