• <li id="00i08"><input id="00i08"></input></li>
  • <sup id="00i08"><tbody id="00i08"></tbody></sup>
    <abbr id="00i08"></abbr>
  • 新聞中心

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

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

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

    本文引用地址:http://www.czjhyjcfj.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 內存管理

    評論


    相關推薦

    技術專區(qū)

    關閉
    主站蜘蛛池模板: 汾西县| 通辽市| 武乡县| 依兰县| 托里县| 额尔古纳市| 文水县| 越西县| 茂名市| 顺昌县| 安泽县| 威海市| 红河县| 常宁市| 霍山县| 江口县| 巴彦县| 岗巴县| 永和县| 辉县市| 黄龙县| 曲阳县| 兰溪市| 县级市| 土默特右旗| 安福县| 九龙坡区| 恩施市| 南安市| 武川县| 延吉市| 同江市| 咸阳市| 茶陵县| 泌阳县| 永寿县| 霍城县| 青河县| 广元市| 铅山县| 绥中县|