久久久久久久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)
主站蜘蛛池模板: 久久久91| 成人在线免费视频 | 91久久看片| 91精品久久久久久久久久小网站 | 欧美三级电影在线播放 | 欧美a级成人淫片免费看 | 国产乱码精品一区二区三区忘忧草 | 欧美偷偷 | 久久精品国产亚洲 | 国产午夜精品久久久 | 日韩视频一区二区在线 | 国产美女一区 | 精品国产乱码久久久久久老虎 | 日韩一区二区在线视频 | 精品亚洲一区二区三区 | 日韩精品久久 | 中文字幕av在线 | 国产视频福利一区 | 亚洲视频免费 | 99久久精品一区二区毛片吞精 | 日韩精品久久久久 | 精品一二三区在线观看 | 国产免费av网 | 国产精品久久久久久久免费大片 | 黄色91在线 | 欧美日韩中文字幕在线播放 | 人人人艹 | 亚洲精品视频在线播放 | 91欧美激情一区二区三区成人 | cao在线| 日韩在线播放一区 | 欧美888| 欧美激情va永久在线播放 | 亚洲先锋影音 | 国产日韩欧美精品一区二区三区 | 在线视频a | 免费在线观看91 | 在线观看中文字幕视频 | 成人av色 | 欧美精品一二三 | 视频1区 |