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 に答える