惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Schneier on Security
Schneier on Security
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
罗磊的独立博客
小众软件
小众软件
H
Help Net Security
Vercel News
Vercel News
M
MIT News - Artificial intelligence
雷峰网
雷峰网
Stack Overflow Blog
Stack Overflow Blog
D
Docker
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Heimdal Security Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
B
Blog
Forbes - Security
Forbes - Security
T
Troy Hunt's Blog
月光博客
月光博客
The Cloudflare Blog
Last Week in AI
Last Week in AI
J
Java Code Geeks
Jina AI
Jina AI
TaoSecurity Blog
TaoSecurity Blog
Google Online Security Blog
Google Online Security Blog
C
Check Point Blog
PCI Perspectives
PCI Perspectives
SecWiki News
SecWiki News
P
Proofpoint News Feed
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Last Watchdog
The Last Watchdog
F
Full Disclosure
T
Threatpost
NISL@THU
NISL@THU
量子位
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队

博客园 - Bruce Lee

Android的界面设计规范-7 Android的界面设计规范-6 Android的界面设计规范-5 Android的界面设计规范-4 Android的界面设计规范-3 Android的界面设计规范-2 Android的界面设计规范-1 Monotouch 移动位于键盘下的内容,自动滚动被键盘遮住的内容 RESTful Web Services,客户端Silverlight提交POST数据报错 Monotouch Copy item from album(从相册拷贝文件出来) Monotouch Save Image To Application(保存相册图片到你的应用程序) Monotouch中使用UINavigationController Monotouch 项目选择Storyborads还是XIBs Montouch 定义一个定制的 View Control类 Monotouch 视图管理周期 Monotouch 常用例子代码 Monotouch在IPAD与IPhone使用UIImagePickerController的图片选择不同的代码 Montouch 增加图片到模拟器(Simulator)的相册中 Monotouch Table View 里面动态增加Table View Cell Switch 触发Switch事件 程序崩溃
Montouch多视图的创建与销毁
Bruce Lee · 2012-09-29 · via 博客园 - Bruce Lee

释放一个引用了另外一个视图的方法,步骤如下。

1) UIViewController A是主视图控制器; B是子视图控制器.

2) A创建了B的实例并且存储B的引用.

3) A增加B的视图为A的子视图.

一切都是正常的,可以看到B正确的显示在A的视图里.

4) A移除B视图.B的视图在代码中不存在任何的引用.

5)调用DidReceiveMemoryWarning (通过模拟或手动调用).

3.0以后不这样做,不需要重载这个函数,把释放内存的代码放到viewDidUnload中去。

这个函数的默认实现是:检查controller是否可以安全地释放它的view(这里加粗的view指的是controller的view属性),比如view本身没有superview并且可以被很容易地重建(从nib或者loadView函数)。

如果view可以被释放,那么这个函数释放view并调用viewDidUnload。

你可以重载这个函数来释放controller中使用的其他内存。但要记得调用这个函数的super实现来允许父类(一般是UIVIewController)释放view

如果你的ViewController保存着view的子view的引用,那么,在早期的iOS版本中,你应该在这个函数中来释放这些引用。而在iOS3.0或更高版本中,你应该在viewDidUnload中释放这些引用。

作者:Bruce Lee
出处:http://www.cnblogs.com/BruceLee521
本博原创文章版权归博客园和本人共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出作者名称和原文连接,否则保留追究法律责任的权利。