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

如何在 Swift 中獲取 UIScrollView 的垂直方向?

How to get UIScrollView vertical direction in Swift?(如何在 Swift 中獲取 UIScrollView 的垂直方向?)
本文介紹了如何在 Swift 中獲取 UIScrollView 的垂直方向?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何在 VC 中獲取向上/向下的滾動/滑動方向?

How can I get the scroll/swipe direction for up/down in a VC?

我想在我的 VC 中添加一個 UIScrollView 或其他東西,可以查看用戶是否向上或向下滑動/滾動,然后隱藏/顯示 UIView 取決于它是否是向上/向下手勢.

I want to add a UIScrollView or something else in my VC that can see if the user swipes/scrolls up or down and then hide/show a UIView depending if it was an up/down gesture.

推薦答案

如果你使用 UIScrollView 那么你可以從 scrollViewDidScroll: 功能.您需要保存它的最后一個位置(contentOffset)并按以下方式更新它:

If you use an UIScrollView then you can take benefit from the scrollViewDidScroll: function. You need to save the last position (the contentOffset) it have and the update it like in the following way:

// variable to save the last position visited, default to zero
private var lastContentOffset: CGFloat = 0

func scrollViewDidScroll(scrollView: UIScrollView!) {
    if (self.lastContentOffset > scrollView.contentOffset.y) {
        // move up
    }
    else if (self.lastContentOffset < scrollView.contentOffset.y) { 
       // move down
    }

    // update the new position acquired
    self.lastContentOffset = scrollView.contentOffset.y
}

當然還有其他方法可以做到這一點.

There are other ways of do it of course this is one to them.

希望對你有所幫助.

這篇關于如何在 Swift 中獲取 UIScrollView 的垂直方向?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

How to subclass UIScrollView and make the delegate property private(如何繼承 UIScrollView 并使委托屬性私有)
Swift - how to get last taken 3 photos from photo library?(Swift - 如何從照片庫中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設置 contentOffset 觸發 scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應用程序式間隙)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動時暫停 NSTimer)
主站蜘蛛池模板: 国产一区免费 | 国产一区二区精品在线 | av网址在线播放 | 99这里只有精品视频 | 国产精品国产a级 | 激情欧美一区二区三区中文字幕 | 国产在线二区 | 99久久国产综合精品麻豆 | 国产日韩欧美激情 | 黄色网址在线免费观看 | 久久噜噜噜精品国产亚洲综合 | 欧美高清一区 | 网站一区二区三区 | 欧美aⅴ | 日韩欧美日韩在线 | 欧美激情国产日韩精品一区18 | 欧美在线a | 久久亚洲免费 | 欧美一级大片免费观看 | www.亚洲 | 亚洲性视频 | 91美女视频| 蜜月aⅴ国产精品 | 国产免费一区二区三区 | 一区二区三区精品在线 | 精品一区二区三区免费视频 | 久草热8精品视频在线观看 午夜伦4480yy私人影院 | 91在线| 中文字幕一区在线 | 污污免费网站 | 天天操天天怕 | 在线精品国产 | www.日韩| 日日骚av| 91在线中文字幕 | 欧美综合久久 | 亚洲毛片 | 国产免费一区 | 亚洲精品久久久久久久不卡四虎 | 亚洲视频一区在线观看 | 亚洲天堂免费在线 |