CAT转移到其他视图工作,转换回来时崩溃

时间:2011-10-25 07:25:09

标签: objective-c ios cocoa-touch 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;

1 个答案:

答案 0 :(得分:0)

这是在UIView UITabBarController和新UIView之间进行转换所需的代码。代码转到IBAction的{​​{1}}之一的按钮UIView

UITabBarController

谢谢你的帮助!我已经尝试了一天以上来实现它。我希望它可以帮助有同样问题的人。