在 CATransition 之后释放视图控制器:我这样做对吗?
我的应用程序正在加载第一个视图(用于登录 Web 服务)。当登录成功时,它会执行 CATransition(基本 kCATransitionFromRight)以显示第二个视图并隐藏第一个视图。我已将转换的委托设置为 self,以便可以使用 -(void)animationDidStop:(CATransition *)theAnimation finish:(BOOL)flag
。
当调用该方法时(在转换结束后),我想释放第一个视图,因为我不再需要它了。但是,当我调用 [firstView release]
(在 animationDidStop:
中)时,保留计数似乎没有改变。我使用 [loginView keepCount]
来检查这一点,因为我知道它并不总是可靠,所以我想知道:我这样做对吗?
谢谢。
My application is loading a first view (used to login into a Web service). When the login is successful, it performs a CATransition (basic kCATransitionFromRight) to show a second view and hides the first view. I've set the delegate of the transition to self so I can use -(void)animationDidStop:(CATransition *)theAnimation finished:(BOOL)flag
.
When that method is called (right after the transition is over) I want to release the first view since I won't need it anymore. However, when I call [firstView release]
(in animationDidStop:
) the retain count doesn't seem to change. I used [loginView retainCount]
to check this and since I know it's not always reliable I was wondering: am I doing this right?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
摘自《Cocoa Touch for iPhone OS 3》一书是类似的方法。
他们设置了一个动画,删除旧的子视图,添加新的子视图,然后提交动画。
taken from the book "Cocoa Touch for iPhone OS 3" is a similar approach.
They set up an animation remove the old subview, add the new one and then commit the animation.
Jilouc 在他的评论中是正确的,忘记检查“retaincount”...
如果你想确保你的对象视图firstView只需
在其
方法中添加一个...
如果你在调试器控制台窗口中得到 NSLog,那么请确保你以正确的方式删除/释放了它...
顺便说一句...正确的方法可能是这样的:
在animationDidStop中:
Jilouc in his comment is right, forget to check "retaincount"...
if you want to be sure that your object view firstView just add a
in its
method...
if you get that NSLog in debugger console window then be sure you had it removed/released in the right way...
btw... the right way could be something like this:
in animationDidStop: