发现的oschina的iPhone端源码bug

唐巧 发布于 2012/09/02 11:59
阅读 1K+
收藏 6

今天开始看oschina开源的iPhone端源码,发现一个bug,在NewBase.m收到memory warning时,不应该调用viewDidUnload方法,会造成程序Crash或无法刷新,重现方法,在新闻页面,用模拟器触发内存警告即可。其实memory warning会自动调用未在界面上的vc 的unload方法。

苹果的文档原文如下,其中说到“Do not use it to release your view controller’s view. You must call super at some point in your implementation to ensure that the default implementation runs. The default implementation attempts to release the view.”

 

The steps that occur during the unload cycle are as follows:

  1. The app receives a low-memory warning from the system.
  2. Each view controller calls its didReceiveMemoryWarning method. If you override this method, you should use it to release any memory or objects that your view controller object no longer needs. Do not use it to release your view controller’s view. You must call super at some point in your implementation to ensure that the default implementation runs. The default implementation attempts to release the view.
  3. If the view cannot be safely released (for example, it is visible onscreen), the default implementation returns.
  4. The view controller calls its viewWillUnload method to inform subclasses that the views are about to be removed. A subclass typically overrides the viewWillUnload method when it needs to save any view properties before the views are destroyed.
  5. It sets its view property to nil.
  6. The view controller calls its viewDidUnload method to inform subclasses that the views were removed. A subclass typically uses this method to release any strong references it has to those views.

加载中
0
junwong
junwong
ok 谢谢指教
0
红薯
红薯
非常感谢报告,这便是开源的力量
红薯
红薯
回复 @唐巧 : 好的,周一让开发人员检查并处理一下 :)
唐巧
唐巧
还有一个比较简单的内存泄漏的bug,我发了一个github上的Pull Request请求了。
0
UIRectEdge
UIRectEdge

分享页面也不应该用这种单纯的网页分享形式来分享吧,可以考虑用WBshareKit这些来做,在登陆的时候没有对输入法进行相应的操作,输入法仍然是return 点击崩溃。感觉这个版本需要改进的地方太多了。

0
挨踢职业人
挨踢职业人
每当看到别人读英文文档时,自己感觉弱爆了
loking
loking
+1001
落舞者
落舞者
+1000
0
YuanJustin
YuanJustin

没有看代码,不过楼主说的稍微隐晦一些

关于viewDidUnload这个方法,有一个前提条件:controlller必须是由initWithNib:bundle:消息创造,该方法才会遇到memoryWarning的时候被调用。相对的,如果没有nib文件,那么无论如何该方法不会被调用。

 

0
crossmix
crossmix
总羡慕别人,其实你也可以的,yes?
0
0
王志湖
王志湖
发现客户端很流畅,呵呵
返回顶部
顶部