久久久久久久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模板網(wǎng)!

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

相關文檔推薦

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 觸發(fā) 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)
主站蜘蛛池模板: 一级特黄网站 | 久久i| 在线2区| 日韩在线一区二区 | 一区二区精品 | 伊人伊成久久人综合网站 | 色999视频 | 国产精品视屏 | 国产精品久久一区二区三区 | 日韩欧美高清 | 亚洲国产成人在线视频 | 日韩免费视频一区二区 | 国产视频一区二区三区四区五区 | 国产一区二区在线看 | 狠狠色网 | 手机看片1 | 一区二区三区在线免费观看视频 | 日韩一区二区三区在线 | 日本一二三区高清 | 精品久久精品 | 国产成人精品久久二区二区91 | 免费在线黄 | 国产一区二区日韩 | 中文字幕精品视频 | 国产久视频 | 久久天天综合 | 国产一区欧美 | 日韩一区二区三区在线视频 | 亚洲精品乱码久久久久久黑人 | 91极品尤物在线播放国产 | 国产一区三区在线 | 精品亚洲一区二区三区 | 69福利影院 | 亚洲一区二区精品 | 久久久国产一区二区三区 | 蜜桃av一区二区三区 | 亚洲+变态+欧美+另类+精品 | 国产一区在线免费 | 久久国产精品久久 | 国产区视频在线观看 | 亚洲一区二区三区四区五区中文 |