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

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

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

問題描述

如何在 VC 中獲取向上/向下的滾動(dòng)/滑動(dòng)方向?

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

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

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: 功能.您需要保存它的最后一個(gè)位置(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
}

當(dāng)然還有其他方法可以做到這一點(diǎn).

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

希望對(duì)你有所幫助.

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

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

相關(guā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(以編程方式設(shè)置 contentOffset 觸發(fā) scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)用程序式間隙)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動(dòng)時(shí)暫停 NSTimer)
主站蜘蛛池模板: 日韩免费高清视频 | 成人高清视频在线观看 | 国产1区| 亚洲精品一区二区三区蜜桃久 | 国产亚洲精品精品国产亚洲综合 | 精品欧美一区二区三区 | 日韩精品区 | 伊人二区| 成人做爰www免费看 午夜精品久久久久久久久久久久 | 日韩伦理一区二区 | 中国一级大毛片 | 欧美黑人体内she精在线观看 | 97人人澡人人爽91综合色 | 91在线资源| 欧美不卡一区二区三区 | 国产日韩一区二区 | 一本久久a久久精品亚洲 | 国产精品久久国产精品 | 别c我啊嗯国产av一毛片 | 久久久久国产一区二区三区 | 久久久久久一区 | 黄a在线播放 | 久久高清 | 国产伦精品一区二区三区高清 | 91久久精品一区二区二区 | 免费视频一区二区 | 欧美日韩一区二区三区四区五区 | 亚洲精品1区 | 91高清视频 | 国产黄色在线观看 | www亚洲精品| 成人99 | 中文字幕精品一区 | 日日夜夜精品视频 | 国产免费又色又爽又黄在线观看 | 亚洲视频免费在线 | 国产一区二区三区免费观看在线 | 久久av一区二区三区 | 国产午夜精品福利 | 日韩在线视频免费观看 | 精品中文字幕视频 |