久久久久久久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.

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

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 內(nèi)]
這個想法是告訴手勢識別器不要吞噬觸摸事件.為此,您需要將 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]; 

這篇關(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(以編程方式設置 contentOffset 觸發(fā) 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)
主站蜘蛛池模板: 久久精品一区 | 91av在线免费 | 国产在线精品一区二区 | 不卡一区| 一区二区三区国产 | 日韩毛片视频 | av黄在线观看 | 女女百合av大片一区二区三区九县 | 日本亚洲欧美 | 国产精品亚洲精品日韩已方 | 99视频免费 | 日韩午夜精品 | 亚洲视频在线观看一区二区三区 | 拍拍无遮挡人做人爱视频免费观看 | 久久久看| 欧美日韩亚洲一区二区 | 久久99深爱久久99精品 | 精品视频一区二区 | 激情一区二区三区 | 亚洲精品二区 | 国产精品中文字幕在线观看 | 欧美在线一区二区三区 | 亚洲综合视频 | 九九热免费看 | 99精品欧美一区二区蜜桃免费 | 草比网站| 亚洲一区久久 | 中文在线一区二区 | 女同久久另类99精品国产 | 久久逼逼| 国产一区二区高清在线 | 91亚洲一区 | 日韩精品国产精品 | 黑人巨大精品欧美黑白配亚洲 | 欧美三级三级三级爽爽爽 | 精品一区二区电影 | 久久久久久国产精品三区 | 欧美久久久久久 | 欧美天堂在线观看 | 欧美一级久久 | 欧美国产精品一区二区三区 |