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

iOS UIScrollView 延遲加載

iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
本文介紹了iOS UIScrollView 延遲加載的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我只是想知道是否有人可以為我解釋這段代碼,以便我可以從中學(xué)習(xí).我試圖讓我的應(yīng)用程序有一個(gè)滾動(dòng)器,它可以從左到右滾動(dòng)大量圖片(來(lái)自互聯(lián)網(wǎng)),但問(wèn)題是,它必須具有延遲加載.所以我做了一些教程并想出了如何去做,但我真的不明白.所以我希望有好心人能解釋一下如何一步一步地延遲加載

i was just wondering if someone could explain this code for me so i can actually learn from it. I am trying to make my app have a scroller that scrolls left to right with loads of pictures (from internet) but the thing is, it must have lazy loading. so i did some tutorials and figured out how to do it but i truly don't understand it. So i was hoping some kind soul would explain how to lazy load step by step

這是我從教程中學(xué)到的代碼:

This is the code i had learned from the tutorials:

-(void)scrollViewDidScroll:(UIScrollView *)myScrollView {
/**
 *  calculate the current page that is shown
 *  you can also use myScrollview.frame.size.height if your image is the exact size of your scrollview
 */
int currentPage = (myScrollView.contentOffset.y / currentImageSize.height);

// display the image and maybe +/-1 for a smoother scrolling
// but be sure to check if the image already exists, you can do this very easily using tags
if ( [myScrollView viewWithTag:(currentPage +1)] ) {
    return;
}
else {
    // view is missing, create it and set its tag to currentPage+1
}

/**
 *  using your paging numbers as tag, you can also clean the UIScrollView
 *  from no longer needed views to get your memory back
 *  remove all image views except -1 and +1 of the currently drawn page
 */
for ( int i = 0; i < currentPages; i++ ) {
    if ( (i < (currentPage-1) || i > (currentPage+1)) && [myScrollView viewWithTag:(i+1)] ) {
        [[myScrollView viewWithTag:(i+1)] removeFromSuperview];
    }
}

}

推薦答案

關(guān)于滾動(dòng)視圖的延遲加載,我強(qiáng)烈建議改用 UITableView.蘋(píng)果在這個(gè)組件的性能方面做得很好.

About Lazy loading on scrollView, I would greatly advised to use UITableView instead. Apple did a great job with performance on this component.

您可以將它們水平放置(請(qǐng)參閱此 EasyTableView 代碼,效果很好)并停止頁(yè)面模式如果您想要連續(xù)滾動(dòng)(pagingEnabled = NO;),那么您將能夠獲得您正在尋找的行為.

You can have them horizontal (see this EasyTableView code, it works great) and stop the page mode if you want a continuous scroll (pagingEnabled = NO;) so you'll be able to get the behavior you are looking for.

這篇關(guān)于iOS UIScrollView 延遲加載的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Stop a UITableView from automatically scrolling(阻止 UITableView 自動(dòng)滾動(dòng))
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運(yùn)行時(shí),使用 iOS 6.0 SDK 并為 iOS 5 Target 構(gòu)建會(huì)導(dǎo)致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創(chuàng)建部分屏幕 UIPageViewController)
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 應(yīng)用程序開(kāi)發(fā)中的導(dǎo)航欄上添加 10 多個(gè)按鈕?)
主站蜘蛛池模板: 午夜寂寞影院在线观看 | 91玖玖 | 国产精品亚洲第一区在线暖暖韩国 | 自拍视频网站 | 欧美日韩在线视频一区二区 | 中文字幕乱码亚洲精品一区 | 国产精品成人国产乱一区 | 欧美色综合网 | 最新国产视频 | 久久99精品国产 | 成人黄色三级毛片 | 欧美日韩视频在线 | 自拍视频在线观看 | 欧美2区| 综合久久综合久久 | 国产在线精品一区 | 亚洲一区日韩 | 99精品国产一区二区三区 | 日韩欧美高清dvd碟片 | 一区二区三区国产精品 | 国产一区二区影院 | 国产yw851.c免费观看网站 | 夜夜爆操 | 免费观看黄a一级视频 | 日韩视频一区二区在线 | 国产亚洲精品精品国产亚洲综合 | 亚洲一区二区久久 | 蜜桃精品视频在线 | 国产黄色大片 | 久久精品av| 日日日日操 | 日韩无| 久久久久中文字幕 | 国产一级在线观看 | 五月天激情电影 | 日本一区二区三区视频在线 | 精品成人在线 | 伊人久久精品一区二区三区 | 亚洲精品在线视频 | www免费视频| 在线观看国产精品视频 |