我的应用程序中有这个代码来为viewcontroller进行转换
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];
它工作正常; 但在第二个视图控制器内我有这个代码消失这个viewcontroller
[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] ??它被释放了吗?
答案 0 :(得分:0)
您需要将其从superView中删除,然后释放您在代码中分配的SecondViewController。
SecondViewController *second = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
因此,既然您拥有此对象,则需要释放它。 所以在隐藏第二个视图并将其从superView中删除之后的某个地方,你需要释放它......
[second release];