在我的应用程序中,我想从上到下启动 UIViewController。所以从 FirstViewController 我启动 MyWebViewController(我需要动画)如下:
MyWebViewController *theWebViewController = [[MyWebViewController alloc] initWithFrame:self.view.bounds];
[self.view addSubview:theWebViewController.view];
在 MyWebViewController 的 loadView 中,我将框架分配给如下视图;
- (void)loadView
{
CGRect theFrame;
theFrame = CGRectMake(0.0, 20.0, mFrame.size.width, 0.0);
UIView *view = [[UIView alloc] init];
view.frame = theFrame;
self.view = view;
[view release];
}
在 viewDidLoad 中,我将框架更改如下:
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor clearColor];
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;
[UIView beginAnimations:@"animateView" context: nil];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.5];
self.view.frame = CGRectMake(0.0, 20.0, mFrame.size.width, mFrame.size.height-20.0);
[UIView commitAnimations];
}
但是动画没有发生。我什至尝试使用此代码从下到上进行动画处理,它工作正常,但反之亦然。请谁能告诉我我做错了什么以及如何实现?
提前致谢!