久久久久久久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)
主站蜘蛛池模板: 51ⅴ精品国产91久久久久久 | 天堂色综合 | 欧美成人精品欧美一级 | 日韩欧美操 | 国产免费一区二区三区网站免费 | 岛国视频 | 欧美一级在线观看 | 国产精品片aa在线观看 | 成人免费视频久久 | 精品国产乱码久久久久久果冻传媒 | 97av| 免费一区| 亚洲精品在线视频 | 久久亚洲精品国产精品紫薇 | 国产精品久久久久一区二区 | 亚洲不卡在线观看 | 精品欧美乱码久久久久久1区2区 | 久久99精品国产自在现线小黄鸭 | 久久久久久美女 | 国产欧美一区二区三区久久 | 欧美日韩最新 | 亚洲午夜电影 | 欧美久久久久久 | 久精品久久 | 亚洲精品乱码久久久久久蜜桃91 | 一区二区不卡高清 | 毛片久久久 | 精品国产乱码久久久久久丨区2区 | 亚洲一区二区久久久 | 欧美精品一区二区三区四区 | 91久久精品一区二区二区 | 91精品国产91久久综合桃花 | 超黄视频网站 | 久久精品日产第一区二区三区 | 美女视频三区 | 免费一区 | 国产一区 | 国产亚洲一区二区三区 | 亚洲一区二区三区四区五区午夜 | 亚洲一区二区久久 | 免费观看a级毛片在线播放 黄网站免费入口 |