我试图向当前视图添加一个子视图(它是一个子类UIViewController的视图,包含多个UIButtons和UILabels),但动画不起作用,子视图刚刚出现动画。UIView动画不适用于UIViewController子类
代码:
[UIView beginAnimations:nil context:nil];
[UIView setAnimaitonCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationTransition:transition forView:thisPersonViewController.view cache:YES];
[self.view addSubView:thisPersonViewController.view];
[UIView commitAnimations];
它只是不工作,但如果我改变forView参数从子视图(thisPersonViewController.view)到self.view,自我。视图做动画,这是古董。
我的xcode版本为4.2,SDK版本为5.0,thx适合任何提供解决方案的人!
===========下面的代码工作正常===============
CATransition *trans = [CATransition animation];
[trans setDuration:0.4f];
[trans setType:kCATransitionReveal];
[trans setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[thisPersonViewController.view layer]addAnimation:trans forKey:kCATransitionReveal];
[self.view addSubview:thisPersonViewController.view];
另一个恼人的问题是,如果我改变CATransition类型为kCATransitionFromBottom或其他动画不能再工作!
抱歉,但这是没有意义的。请仔细研究[MVC](https://developer.apple.com/library/ios/#documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html)模式 – vikingosegundo 2012-02-04 17:39:45
给你一个提示:视图不能是一个视图控制器 – vikingosegundo 2012-02-04 17:40:19
的子类,听起来正确 – vikingosegundo 2012-02-04 17:46:16