久久久久久久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)
主站蜘蛛池模板: 中文字字幕一区二区三区四区五区 | 亚洲精品国产综合区久久久久久久 | 国产日韩欧美一区 | 亚洲一区二区三区在线免费观看 | 久久999 | 亚洲一区二区免费视频 | 亚洲精品一区二区 | 91视频大全| 国产精品美女久久久久久免费 | 97国产精品视频人人做人人爱 | 小h片免费观看久久久久 | 成人福利在线 | 久久国产精品免费一区二区三区 | 亚洲高清视频一区二区 | 精品免费观看 | 精品伦精品一区二区三区视频 | 亚洲精品久久视频 | www.亚洲区 | 一区二区三区四区在线 | 午夜精品一区二区三区在线视 | 日韩精品免费在线观看 | 国产一区影院 | 激情欧美一区二区三区中文字幕 | 亚洲成人精品 | 欧美一级片在线播放 | 91精品国产乱码久久久久久久久 | 欧美bondage紧缚视频 | 992人人草| 国产日韩一区二区三免费高清 | 久久午夜视频 | 精品伦精品一区二区三区视频 | 中文字幕高清av | 青青久久 | 精品www| www.亚洲国产精品 | 午夜免费在线电影 | 精产国产伦理一二三区 | 99视频在线免费观看 | 天天夜夜操 | 狠狠av| 黑人一级片视频 |