久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

removefromsuperview 會釋放scrollview 的對象嗎?

does removefromsuperview releases the objects of scrollview?(removefromsuperview 會釋放scrollview 的對象嗎?)
本文介紹了removefromsuperview 會釋放scrollview 的對象嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

 for(UIView *subview in [scrollView subviews]) {NSLog(@"subviews Count=%d",[[scrollView subviews]count]);//[子視圖發布];[子視圖 removeFromSuperview];}

在上述方法中,如果我使用 [subview removeFromSuperview]; 它工作正常...但如果我使用[subview release];它崩潰了..我想知道兩者是否相同或它們之間有什么區別?

解決方案

@MathieuK 是正確的,但值得深入挖掘,因為它是 ObjC 中一個非常重要的概念.你不應該在一個你沒有顯式或隱式 -retain 的對象上調用 -release(通過調用 三個神奇的詞).您不會調用 -release 來釋放對象.你調用它來釋放 對對象的保持.scrollview 是否保留其子視圖不是您的事(它確實保留了其子視圖,但仍然不是您的事).-removeFromSuperview 是否調用 -release 也不是你的事.那是在滾動視圖和它的子視圖之間.重要的是,當你關心對象時你保留它們,當你不再關心它們時釋放它們,讓系統的其余部分負責保留和釋放它所關心的.p>

  for(UIView *subview in [scrollView subviews]) {
    NSLog(@"subviews Count=%d",[[scrollView subviews]count]);
    //[subview release];
    [subview removeFromSuperview];
}

in the above method if i use [subview removeFromSuperview]; it works fine...but if i use [subview release];It crashes..i want to know that if both are same or is there any difference between them?

解決方案

@MathieuK is correct, but it's worth digging deeper into this, because it's a very important concept in ObjC. You should never call -release on an object you didn't -retain explicitly or implicitly (by calling one of the Three Magic Words). You don't call -release in order to deallocate an object. You call it to release the hold you have put on the object. Whether scrollview is retaining its subviews is not your business (it does retain its subviews, but its still not your business). Whether -removeFromSuperview calls -release is also not your business. That's betweeen the scrollview and its subviews. All that matters is that you retain objects when you care about them and release them when you stop caring about them, and let the rest of the system take care of retaining and releasing what it cares about.

這篇關于removefromsuperview 會釋放scrollview 的對象嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
UIImageView zoom and pinch in UIScrollView(UIImageView 在 UIScrollView 中縮放和捏合)
How can i add more than 10 buttons on a navigationbar in iphone application development?(如何在 iphone 應用程序開發中的導航欄上添加 10 多個按鈕?)
UIScrollView scrolling only with one finger(UIScrollView 只能用一根手指滾動)
Using UITouch inside a UIScrollView(在 UIScrollView 中使用 UITouch)
主站蜘蛛池模板: 国产日韩欧美激情 | 国产精品久久久久久久久免费高清 | 国产精品一区二区在线播放 | 国产一区二区三区高清 | 农村黄性色生活片 | 99国产精品久久久久 | 午夜欧美 | 日本精品一区二区三区在线观看视频 | 日韩在线视频一区 | 一道本在线 | 亚洲综合一区二区三区 | av中文字幕在线播放 | 欧美综合一区 | 91精品国产综合久久久久久蜜臀 | 亚洲精品免费在线 | 国产日韩欧美中文字幕 | 97在线超碰 | 久久久久九九九女人毛片 | 日韩精品在线一区 | 欧美韩一区二区 | 国产第一页在线观看 | 亚洲国产成人精品女人久久久 | 天天看夜夜 | 国产视频一区在线 | 99爱在线| 久久99深爱久久99精品 | 日韩三极| 七七婷婷婷婷精品国产 | 日本中出视频 | 亚洲精品视频在线看 | 中文字幕综合 | 欧美综合在线视频 | 日本一区二区三区视频在线 | 国产专区视频 | 久久久久国产 | 国产精品久久久久久久久久久久冷 | 久久久久国产精品 | 亚洲视频二区 | 91在线免费视频 | 亚洲综合色视频在线观看 | 欧美v日韩v |