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

無限水平滾動 UIScrollView

Infinite horizontal scrolling UIScrollView(無限水平滾動 UIScrollView)
本文介紹了無限水平滾動 UIScrollView的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個內容大小為 1200x480 的 UIScrollView.我有一些圖像視圖,其寬度加起來為 600.當向右滾動時,我只需增加內容大小并設置偏移量以使一切順利(然后我想添加其他圖像,但這并不重要現在).所以基本上,當前在視口中的圖像保留在左側某處,最終會從超級視圖中刪除.

I have a UIScrollView whose content size is 1200x480. I have some image views on it, whose width adds up to 600. When scrolling towards the right, I simply increase the content size and set the offset so as to make everything smooth (I then want to add other images, but that's not important right now). So basically, the images currently in the viewport remain somewhere on the left, eventually to be removed from the superview.

現在,我在向左滾動時發生的問題.我所做的是將圖像移動到內容大小的末尾(因此將 600 添加到每個圖像視圖的 origin.x),然后相應地設置內容偏移量.當手指在屏幕上并且用戶拖動時它起作用(scrollView.isTracking = YES).當用戶向左滾動并松開時(scrollView.isTracking = NO),圖像視圖最終向右移動得太快并且幾乎立即消失.有誰知道我怎樣才能讓圖像很好地移動并且即使用戶沒有手動拖動視圖并且已經放手也不會消失?

Now, the problem that I have happens when scrolling towards the left. What I do is I move the images to the end of the content size (so add 600 to each image view's origin.x), and then set the content offset accordingly. It works when the finger is on the screen and the user drags (scrollView.isTracking = YES). When the user scrolls towards the left and lets go (scrollView.isTracking = NO), the image views end up moving too fast towards the right and disappear almost instantly. Does anyone know how I could have the images move nicely and not disappear even when the user's not manually dragging the view and has already let go?

這是我的水平拖動代碼:

Here's my code for dragging horizontally:

-(void) scrollViewDidScroll:(UIScrollView *)scrollView {
    CGPoint offset = self.scrollView.contentOffset;
    CGSize size = self.scrollView.contentSize;

    CGPoint newXY = CGPointMake(size.width-600, size.height-480);

    // this bit here allows scrolling towards the right
    if (offset.x > size.width - 320) {
        [self.scrollView setContentSize:CGSizeMake(size.width+320, size.height)];
        [self.scrollView setContentOffset: offset];
    }

    // and this is where my problem is:
    if (offset.x < 0) {
        for (UIImageView *imageView in self.scrollView.subviews) {
            CGRect frame = imageView.frame;
            [imageView setFrame:CGRectMake
                (frame.origin.x+newXY.x, frame.origin.y, 200, frame.size.height)];
        }
        [self.scrollView setContentOffset:CGPointMake(newXY.x+offset.x, offset.y)];
    } 
}

現在可以使用了 - 我查看了 StreetScroller,現在一切正常.

This is now working - I had a look at StreetScroller and it's all good now.

但是,我現在想放大滾動視圖,但從未調用 viewForZoomingInScrollView.無法放大內容尺寸較大的滾動視圖嗎?

However, I now want to zoom in on the scrollview, but viewForZoomingInScrollView is never called. Is it not possible to zoom in on a scrollview with a large content size?

推薦答案

這里有一些方法.只需使用網站搜索...

There are some approaches floating around here. Just use the site search …

如果您想要 Apple 創建的更官方"示例,請查看 StreetScroller 演示.有關此示例的更多信息,請查看去年的 WWDC 會議編號.104 高級滾動查看技術.

If you want an more "official" example created by Apple take a look at the StreetScroller Demo. For some more information about this example take a look at last years WWDC session no. 104 Advanced Scroll View Techniques.

Github 上還有一個 UIScrollView 子類叫BAGPagingScrollView,就是分頁&無限,但它有一些錯誤你必須自己修復,因為它沒有處于積極開發中(尤其是 goToPage: 方法會導致問題).

There is also an UIScrollView subclass on Github called BAGPagingScrollView, which is paging & infinite, but it has a few bugs you have to fix on your own, because it's not under active development (especially the goToPage: method leads to problems).

這篇關于無限水平滾動 UIScrollView的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設置滾動視圖內容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
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 可縮放?)
主站蜘蛛池模板: 国产精品日日做人人爱 | 午夜免费看 | 国产精品一区二区福利视频 | 国产精品视频一区二区三区, | 欧美日韩综合 | 99精品国产一区二区三区 | 久久精品一区二区 | 日韩a在线| 日韩www | 一区二区三区在线免费 | 午夜视频在线观看网址 | 成人国产精品久久久 | 午夜精品久久久久久久久久久久久 | 日本精品久久久一区二区三区 | 日韩中文字幕网 | 精品欧美 | 天天人人精品 | 欧美一区二区三区四区在线 | 欧美极品在线视频 | 日韩网站免费观看 | 亚洲欧美在线一区 | 日韩精品一区二区三区在线播放 | 免费人成在线观看网站 | 伊人网站在线观看 | 超碰人人插 | 天天躁日日躁aaaa视频 | 91av视频在线观看 | 超碰一区二区 | 亚洲欧美视频 | 国产91一区二区三区 | h视频免费在线观看 | 日韩欧美视频 | 国产三级精品视频 | 欧美成人精品一区二区三区 | 亚洲国产精品一区二区第一页 | 国产精品三级 | 91精品国产自产在线老师啪 | 亚洲一区欧美 | 久久精品 | 国产99精品 | 久久精品久久综合 |