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

UIScrollView 防止視圖控制器上的 touchesBegan、touch

UIScrollView prevents touchesBegan, touchesMoved, touchesEnded on view controller(UIScrollView 防止視圖控制器上的 touchesBegan、touchesMoved、touchesEnded)
本文介紹了UIScrollView 防止視圖控制器上的 touchesBegan、touchesMoved、touchesEnded的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在我的視圖控制器(UIViewController 的自定義子類)中處理幾個(gè) UI 組件的觸摸.它有方法 touchesBegan:withEvent:touchesMoved:withEvent:touchesEnded:withEvent:.它工作正常.然后我添加了一個(gè)滾動(dòng)視圖(UIScrollView)作為層次結(jié)構(gòu)中的頂視圖.

I am handling touches for a couple of my UI components in my view controller (custom subclass of UIViewController). It has methods touchesBegan:withEvent:, touchesMoved:withEvent:, and touchesEnded:withEvent:. It was working fine. Then I added a scroll view (UIScrollView) as the top view in the hierarchy.

現(xiàn)在我在視圖控制器上的觸摸處理程序不起作用.他們不會(huì)被召喚.有趣的是,我在滾動(dòng)視圖中有各種其他的 UI 組件可以工作.有些是按鈕,有些是自定義視圖,它們定義了自己的 touchesBegan:withEvent: 等.唯一不起作用的是視圖控制器上的觸摸處理程序.

Now my touch handlers on the view controller don't work. They don't get called. The interesting thing is, I have various other UI components within the scroll view that do work. Some are buttons, some are custom views that define their own touchesBegan:withEvent:, etc. The only thing that doesn't work is the touch handlers on the view controller.

我想這可能是因?yàn)闈L動(dòng)視圖出于自己的目的攔截了這些觸摸,但我將 UIScrollView 子類化,只是為了看看我是否可以讓它工作,我總是從 返回 YES>touchesShouldBegin:withEvent:inContentView:NO 始終來自 touchesShouldCancelInContentView:.還是不行.

I thought maybe it's because the scroll view is intercepting those touches for its own purposes, but I subclassed UIScrollView and just to see if I could get it to work I am returning YES always from touchesShouldBegin:withEvent:inContentView: and NO always from touchesShouldCancelInContentView:. Still doesn't work.

如果它有所不同,我的視圖控制器位于標(biāo)簽欄控制器中,但我認(rèn)為它不相關(guān).

If it makes a difference my view controller is within a tab bar controller, but I don't think it's relevant.

有沒有人遇到過這個(gè)問題并有現(xiàn)成的解決方案?我的猜測(cè)是滾動(dòng)視圖猴子在響應(yīng)者鏈上.我可以猴子回來嗎?我想如果我想不出其他任何東西,我會(huì)將滾動(dòng)視圖下的頂級(jí)視圖設(shè)為自定義視圖并將消息轉(zhuǎn)發(fā)到視圖控制器,但看起來很笨拙.

Has anyone had this problem and have a ready solution? My guess is the scroll view monkeys up the responder chain. Can I monkey it back? I guess if I can't figure anything else out I'll make the top level view under my scroll view be a custom view and forward the messages on to the view controller, but seems kludgy.

推薦答案

創(chuàng)建 UIScrollView 類的子類并覆蓋 touchesBegan: 和其他觸摸方法如下:

create a subclass of UIScrollView class and override the touchesBegan: and other touch methods as follows:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

// If not dragging, send event to next responder
  if (!self.dragging){ 
    [self.nextResponder touchesBegan: touches withEvent:event]; 
  }
  else{
    [super touchesBegan: touches withEvent: event];
  }
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

// If not dragging, send event to next responder
    if (!self.dragging){ 
     [self.nextResponder touchesMoved: touches withEvent:event]; 
   }
   else{
     [super touchesMoved: touches withEvent: event];
   }
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{

  // If not dragging, send event to next responder
   if (!self.dragging){ 
     [self.nextResponder touchesEnded: touches withEvent:event]; 
   }
   else{
     [super touchesEnded: touches withEvent: event];
   }
}

這篇關(guān)于UIScrollView 防止視圖控制器上的 touchesBegan、touchesMoved、touchesEnded的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

iOS - Using storyboard and autolayout to center the UIScrollView(iOS - 使用故事板和自動(dòng)布局使 UIScrollView 居中)
get index or tag value from imageview tap gesture(從 imageview 點(diǎn)擊手勢(shì)獲取索引或標(biāo)簽值)
UIScrollView not scrolling regardless of large contentSize(無論內(nèi)容大小如何,UIScrollView 都不會(huì)滾動(dòng))
Clean autorotation transitions in a paging UIScrollView(清除分頁(yè) UIScrollView 中的自動(dòng)旋轉(zhuǎn)轉(zhuǎn)換)
UIScrollView zooming with Auto Layout(UIScrollView 使用自動(dòng)布局縮放)
How to create an image from a UIView / UIScrollView(如何從 UIView/UIScrollView 創(chuàng)建圖像)
主站蜘蛛池模板: 91小视频在线观看 | 国产中文字幕一区 | 午夜视频免费观看 | 日韩精品第一页 | 91久久精品日日躁夜夜躁欧美 | 中文字幕一区二区三区四区 | 亚洲精品国产精品国自产观看浪潮 | 中文字幕永久在线 | 国产中文字幕一区二区 | 91精品国产乱码久久久 | 久久高清免费视频 | 成人黄色免费视频 | 日韩中文字幕一区 | 成人免费福利视频 | www.狠狠操.com | 久操福利 | 久久久精| 国产精品一区二区性色av | 成人免费毛片入口 | www.青青草 | 欧美日韩在线不卡 | 激情综合色 | 91看片在线观看 | 成人精品视频在线观看 | 三上悠亚一区 | 日韩色黄大片 | 黑人精品xxx一区一二区 | 亚洲日本中文字幕 | 欧美做受69 | 成年人国产 | 影音先锋国产精品 | 成人羞羞国产免费 | 欧美在线视频一区二区 | 亚洲一区二区在线 | 日本中文字幕一区 | 久久亚洲精品视频 | 日韩精品在线观看视频 | av久久 | av一区二区三区 | 天天操夜夜摸 | 精品黑人一区二区三区国语馆 |