0

在我的应用程序中,我想从上到下启动 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];
} 

但是动画没有发生。我什至尝试使用此代码从下到上进行动画处理,它工作正常,但反之亦然。请谁能告诉我我做错了什么以及如何实现?

提前致谢!

4

1 回答 1

0

我不认为将高度设置为 0。而是:

- (void)loadView
{
    CGRect theFrame;
    theFrame = CGRectMake(0.0, -mframe.size.height + 20, mFrame.size.width, m.frame.size.height - 20);
    UIView *view = [[UIView alloc] init];
    view.frame = theFrame;
    self.view = view;
    [view release];
}

添加时,您希望将框架设置在视图上方和视图之外。然后将其移动到动画中的适当位置。

于 2012-08-03T12:28:46.790 回答