[英]IOS: custom transition for a viewController
我的应用程式中有这个程式码,可以为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];
它工作正常; 但是在第二个视图控制器内部,我有这段代码使这个视图控制器消失了
[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]? 它发布了吗?
您需要将其从superView中删除,然后释放您在代码中分配的SecondViewController。
SecondViewController *second = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
因此,由于您拥有此对象,因此需要释放它。 因此,在隐藏第二个视图并将其从superView中删除后的某个地方,您需要释放它...
[second release];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.