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

拖動按鈕時ScrollView不滾動

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

問題描述

我有一個滾動視圖,當它上面沒有按鈕時會滾動.現在確實如此,并且當拖動鼠標(在模擬器上)時,什么也沒有發生(我認為是因為按鈕被按下了).我怎樣才能做到這一點?

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?

推薦答案

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

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 設置為 YES.
  2. 子類 UIScrollView 并覆蓋 touchesShouldCancelInContentView 以在內容視圖對象是 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];
}

這篇關于拖動按鈕時ScrollView不滾動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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| 久草在线中文888 | 亚洲精品久久久蜜桃 | 一级毛片在线播放 | 久久婷婷国产 | 欧美精品一区二区三区在线 | 成人免费视屏 | 欧美二区在线 | 粉嫩国产精品一区二区在线观看 | 国产一区二区三区在线 | 国产精品性做久久久久久 | 精精国产xxxx视频在线播放7 | 欧美国产精品一区二区 | 99精品国产一区二区三区 | 日韩在线国产精品 | 亚洲精品久久视频 | 国产真实精品久久二三区 | 国产精品视频一二三 | 欧美成年黄网站色视频 | 国产高清一区二区三区 | 久草在线青青草 | 天天干夜夜操 | 成人精品视频在线观看 | 日韩在线一区二区三区 | 精品美女在线观看 | www.久久 | 羞羞视频在线观看网站 | 国产精品毛片无码 | 欧美在线视频一区 | 一区二区三区四区不卡 | 精品一二三区在线观看 | 成人乱人乱一区二区三区软件 | 国产精品久久国产精品久久 | 免费黄色片在线观看 | 999精品在线观看 | 激情自拍偷拍 | 成人一区二区三区 | 国产欧美一区二区三区另类精品 | 亚洲精品永久免费 |