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

ScrollView 手勢識別器吃掉所有的觸摸事件

ScrollView gesture recognizer eating all touch events(ScrollView 手勢識別器吃掉所有的觸摸事件)
本文介紹了ScrollView 手勢識別器吃掉所有的觸摸事件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個 UIScrollView,我添加了一個點擊手勢識別器來顯示/隱藏一些 UI 覆蓋,使用:

I have a UIScrollView to which I added a single tap gesture recognizer to show/hide some UI overlay using:

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[scrollView addGestureRecognizer:singleTap];

和:

- (void)handleTap:(UITapGestureRecognizer *)sender {
    // report click to UI changer
}

我在 UIScrollView 的底部添加了一個簡易表格視圖.一切正常(水平和垂直滾動),但問題是點擊只能被手勢識別器識別(上圖),而不是簡單的表格視圖.如果我刪除注冊手勢偵聽器的行,一切正常,表格視圖會通知自己點擊.

I added an easy table view to the bottom of the UIScrollView. Everything works right (scrolling both horizontally and vertically) but the problem is that taps are recognized only by the gesture recognizer (above), but not by the easy table view. If I remove The line that registers the gesture listener, everything works fine, the table view notices taps on itself.

就好像手勢識別器函數吃掉"了表格視圖上的點擊事件,而不是向下傳播它們.

It's as if the gesture recognizer function "eats" the tap events on the table view and doesn't propagate them downward.

感謝任何幫助

推薦答案

這應該可以解決您的問題.
檢測 UIScrollView 上的觸摸事件 AND在 UIView 的組件上[放置在 UIScrollView 內]
這個想法是告訴手勢識別器不要吞噬觸摸事件.為此,您需要將 singleTap 的 cancelsTouchesInView 屬性設置為 NO,默認為 YES.

This should solve your problem.
Detect touch event on UIScrollView AND on UIView's components [which is placed inside UIScrollView]
The idea is to tell the gesture recognizer to not swallow up the touch events. To do this you need to set singleTap's cancelsTouchesInView property to NO, which is YES by default.

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
singleTap.cancelsTouchesInView = NO;
[scrollView addGestureRecognizer:singleTap]; 

這篇關于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)
主站蜘蛛池模板: 四虎在线视频 | 三级视频在线 | 国产在线天堂 | 久草免费福利 | 四虎看片 | 欧美日韩中文在线 | 久久国产一区 | 国产wwwwww| 草草在线观看 | 在线一区二区视频 | 国产免费无遮挡 | www.啪啪| 亚洲精品国产精品乱码不卡 | 亚洲久久久 | 国产乱码精品一区二区三 | 特大黑人巨交吊性xxxx视频 | 91久久久久久久 | 在线观看欧美 | 97久久久久 | 91精品亚洲 | 亚洲精品一区二区三区在线 | 九九色影院 | 久久精品导航 | 国产三级午夜理伦三级 | 日韩1区2区 | 久热综合 | 日韩成人精品 | 日韩国产在线观看 | 夜夜操av| 亚色视频| 日韩一级淫片 | 天天射影院 | 国产三级久久 | 性生活毛片 | aaaaaa毛片 | 色婷婷香蕉在线一区二区 | 综合色婷婷一区二区亚洲欧美国产 | aaa黄色片 | 成人欧美激情 | 欧美三级 欧美一级 | 男人爱看的网站 |