0

ビューコントローラーの遷移を行うために、アプリにこのコードがあります

SecondViewController *second = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
    [self.view addSubview:second.view];
    [second.view setFrame:CGRectMake(320, 0, 320, 480)];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.40]; //the double represents seconds
    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    [second.view setFrame:CGRectMake(0, 0, 320, 480)];
    [UIView commitAnimations];

そしてそれはうまくいきます。しかし、2番目のビューコントローラー内には、このビューコントローラーを非表示にするためのこのコードがあります

[UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.40]; //the double represents seconds
    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    [self.view setFrame:CGRectMake(320, 0, 320, 480)];
    [UIView commitAnimations];

それは正常に動作しますが、それを解放する方法は何ですか?呼び出すときに割り当てたこの秒をどこで解放できますか?? [self.view removeFromSuperView] と書いたら?? 発売されてます??

4

1 に答える 1

0

それを superView から削除してから、コードで割り当てた SecondViewController を解放する必要があります。

SecondViewController *second = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];

したがって、このオブジェクトを所有しているので、解放する必要があります。したがって、2 番目のビューを非表示にして superView から削除した後、どこかで解放する必要があります...

[second release];
于 2012-05-09T00:05:36.233 に答える