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

iOS UIScrollView 延遲加載

iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
本文介紹了iOS UIScrollView 延遲加載的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

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

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

這是我從教程中學到的代碼:

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];
    }
}

}

推薦答案

關于滾動視圖的延遲加載,我強烈建議改用 UITableView.蘋果在這個組件的性能方面做得很好.

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

您可以將它們水平放置(請參閱此 EasyTableView 代碼,效果很好)并停止頁面模式如果您想要連續滾動(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.

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

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

相關文檔推薦

Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構建會導致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創建部分屏幕 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 應用程序開發中的導航欄上添加 10 多個按鈕?)
主站蜘蛛池模板: 雨宫琴音一区二区在线 | 国产人成精品一区二区三 | 亚洲精品在线免费看 | 亚洲国产中文字幕 | 爱高潮www亚洲精品 中文字幕免费视频 | 国产成人99 | 中文字幕一区在线 | 中文字幕在线看第二 | 国产1区2区3区 | 日韩av在线免费 | 久久福利电影 | 中文字幕日韩欧美一区二区三区 | 特黄特色大片免费视频观看 | 欧美一区二区三区一在线观看 | 日本三级电影免费观看 | 中文字幕av第一页 | www.天天干.com| 天天综合久久 | 亚洲视频免费在线观看 | 免费av毛片 | 午夜视频在线观看视频 | 成人做爰www免费看视频网站 | 国产日韩欧美在线观看 | 国产日韩欧美电影 | 国产免费一区二区 | 成人在线视频网址 | 天天操天天干天天透 | 欧美在线视频网 | 97精品一区二区 | 午夜精品久久久久久久99黑人 | 久久国产传媒 | 国产区在线观看 | 国产一区二区三区免费 | 精品一区二区三区四区视频 | 中文字幕亚洲欧美 | 不卡一区二区在线观看 | 午夜精品一区二区三区在线 | 天堂在线网 | 日韩中文字幕第一页 | 国产一区二区欧美 | 99热热|