a一级爱做片免费观看欧美,久久国产一区二区,日本一二三区免费,久草视频手机在线观看

新聞中心

EEPW首頁 > 嵌入式系統 > 設計應用 > iOS目前版本的內存管理差異有哪些呢?

iOS目前版本的內存管理差異有哪些呢?

作者: 時間:2016-10-29 來源:網絡 收藏

本文引用地址:http://www.j9360.com/article/201610/306006.htm

說到技術那么大家都知道版本的升級那是在所難免的了,那么如果你是在學習的話那么也會有些關于版本的問題,這不前兩天就有同學問老師:iOS目前版本的差異有哪些呢?如下就是我贏職場老師給學員的解答,由尚網小編整理希望對大家有所幫助。

iOS6.0以前版本

1

收到內存警告:調用 didReceiveMemoryWarning 內調用 super 的 didReceiveMemoryWarning 會將 controller 的 view 進行釋放。所以我們不能將controller的view再次釋放。

處理方法:

-(void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];//如沒有顯示在window上,會自動將self.view釋放。

// 6.0以前,不用在此做處理,self.view釋放之后,會調用下面的viewDidUnload函數,在viewDidUnload函數中做處理就可以了。

}

-(void)viewDidUnload

{

// Release any retained subviews of the main view.不包含self.view

[super viewDidUnload];

//處理一些內存和資源問題。

}但是到了IOS 6.0之后,這里又有所變化,IOS 6.0內存警告的 viewDidUnload 被屏蔽,即又回到了IOS 6.0以前版本時期的方式。

收到內存警告:調用 didReceiveMemoryWarning 內調用 super 的 didReceiveMemoryWarning 調只是釋放 controller 的 resouse,不會釋放view。

處理方法:

-(void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];//即使沒有顯示在window上,也不會自動的將self.view釋放。

// Add code to clean up any of your own resources that are no longer necessary.

// 此處做兼容處理需要加上ios6.0的宏開關,保證是在6.0下使用的,6.0以前屏蔽以下代碼,否則會在下面使用self.view時自動加載viewDidLoad

if ([self.view window] == nil)// 是否是正在使用的視圖

{

// Add code to preserve data stored in the views that might be

// needed later.

// Add code to clean up other strong references to the view in

// the view hierarchy.

self.view = nil;// 目的是再次進入時能夠重新加載調用viewDidLoad函數。

}



關鍵詞: ios 內存管理

評論


相關推薦

技術專區

關閉