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

拖動按鈕時ScrollView不滾動

ScrollView not scrolling when dragging on buttons(拖動按鈕時ScrollView不滾動)
本文介紹了拖動按鈕時ScrollView不滾動的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一個滾動視圖,當(dāng)它上面沒有按鈕時會滾動.現(xiàn)在確實(shí)如此,并且當(dāng)拖動鼠標(biāo)(在模擬器上)時,什么也沒有發(fā)生(我認(rèn)為是因?yàn)榘粹o被按下了).我怎樣才能做到這一點(diǎn)?

I have a scroll view that used to scroll when it didn't have buttons all over it. Now it does, and when dragging the mouse (on simulator) nothing happens (i think because the buttons are being pushed). How can I make this right?

推薦答案

發(fā)生這種情況是因?yàn)?UIScrollViewUIButton 子視圖(我假設(shè)按鈕作為子視圖添加到您的case) 正在跟蹤觸摸而不是滾動視圖.UIScrollView 方法 touchesShouldCancelInContentView 是這里的關(guān)鍵.根據(jù)其描述:如果view不是UIControl對象,則默認(rèn)返回YES;否則返回NO.",即對于UIControl 對象(按鈕),UIScrollView 不會嘗試取消阻止?jié)L動的觸摸.

This is happening because UIButton subviews of the UIScrollView (I assume buttons are added as subviews in your case) are tracking the touches and not the scroll view. UIScrollView method touchesShouldCancelInContentView is the key here. According to its description: "The default returned value is YES if view is not a UIControl object; otherwise, it returns NO.", i.e. for UIControl objects (buttons), UIScrollView does not attempt to cancel touches which prevents scrolling.

所以,要允許使用按鈕滾動:

So, to allow scrolling with buttons:

  1. 確保 UIScrollView 屬性 canCancelContentTouches 設(shè)置為 YES.
  2. 子類 UIScrollView 并覆蓋 touchesShouldCancelInContentView 以在內(nèi)容視圖對象是 UIButton 時返回 YES,如下所示:
  1. Make sure UIScrollView property canCancelContentTouches is set to YES.
  2. Subclass UIScrollView and override touchesShouldCancelInContentView to return YES when content view object is a UIButton, like this:

- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
    if ( [view isKindOfClass:[UIButton class]] ) {
        return YES;
    }

    return [super touchesShouldCancelInContentView:view];
}

這篇關(guān)于拖動按鈕時ScrollView不滾動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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 在滾動時暫停 NSTimer)
主站蜘蛛池模板: 九九九视频在线 | 中文字幕日韩一区 | 在线观看中文字幕 | 91在线观看视频 | 亚洲精品视频免费看 | 久久精品国产99国产 | 我要看免费一级毛片 | 国产成人精品久久 | 蜜桃精品视频在线 | 欧美另类视频 | 一本一道久久a久久精品综合 | 免费观看的av毛片的网站 | 亚洲综合久久久 | 成人a视频在线观看 | 国产伦精品一区二区三区照片91 | 中文字幕二区三区 | 久久精品国产一区二区三区 | 国产二区视频 | 人人精品 | 国产精品麻| 久草免费在线视频 | 欧洲一区二区三区 | 91精品久久久久 | 欧美一卡二卡在线观看 | 国产精品综合视频 | 综合成人在线 | 真人女人一级毛片免费播放 | 精品亚洲一区二区三区四区五区高 | 91欧美激情一区二区三区成人 | av在线播放不卡 | 国产成人综合在线 | 国产91丝袜在线18 | 第四色影音先锋 | 91视频入口| 2021天天干夜夜爽 | 欧美综合一区二区三区 | 96久久久久久 | 亚洲一区二区三区免费在线观看 | 亚洲欧美日韩精品久久亚洲区 | 免费毛片网站在线观看 | 天堂视频免费 |