自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

IOS學(xué)習(xí)之UIScrollView touch觸摸事件

移動(dòng)開發(fā) iOS
UIScrollView本身無法處理touch事件。要想實(shí)現(xiàn),必須對(duì)UIScrollView上的subView做touch處理原理十分簡單,來看本文內(nèi)容如何解決。

IOS學(xué)習(xí)之UIScrollView touch觸摸事件是本文要介紹的內(nèi)容,UIScrollView本身無法處理touch事件。要想實(shí)現(xiàn),必須對(duì)UIScrollView上的subView做touch處理原理十分簡單,好比要響應(yīng)scrollView上的UIImageView,那么請(qǐng)創(chuàng)建一個(gè)UIImageVIew的子類,由這個(gè)自定義的UIImageView來處理touch事件

頭文件聲明如下,供參考:

  1. #import <Foundation/Foundation.h> 
  2.  
  3. @protocol ImageTouchDelegate  
  4. -(void)imageTouch:(NSSet *)touches withEvent:(UIEvent *)event whichView:(id)imageView;  
  5. @end  
  6.  
  7. @interface ImageTouchView : UIImageView   
  8. {  
  9.         id<ImageTouchDelegate>  delegate;  
  10.         BOOL delegatrue;  
  11. }  
  12. @property(nonatomic,assign)id<ImageTouchDelegate> delegate;  
  13. @end 

這個(gè)是頭文件,源文件可以是這個(gè)這樣子

  1. @implementation ImageTouchView  
  2. @synthesize     delegate;  
  3. -(id)initWithFrame:(CGRect)frame  
  4. {  
  5.         if (self == [super initWithFrame:frame])   
  6.         {  
  7.                 [self setUserInteractionEnabled:YES];  
  8.                 delegatrue=YES;  
  9.         }  
  10.         return  self;  
  11. }  
  12. - (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view  
  13. {  
  14.         return YES;  
  15. }  
  16. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event  
  17. {  
  18.         if (delegatrue)  
  19.         {  
  20.                 [delegate imageTouch:touches withEvent:event whichView:self];  
  21.         }   

小結(jié):IOS學(xué)習(xí)之UIScrollView touch觸摸事件的內(nèi)容介紹完了,希望本文對(duì)你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2023-03-10 16:40:21

Frameworkinput觸摸事件

2011-07-22 13:23:56

IOS UI ScrollView

2013-04-15 15:22:06

2021-08-11 14:29:20

鴻蒙HarmonyOS應(yīng)用

2017-12-21 15:42:08

iOS傳遞機(jī)制

2013-07-15 14:46:34

iOS開發(fā)UIScrollVie移動(dòng)開發(fā)

2013-03-29 11:06:24

iOS開發(fā)滾動(dòng)視圖UIScrol

2016-12-08 22:59:47

觸摸事件android

2013-04-24 11:15:56

Android開發(fā)Touch事件傳遞機(jī)制

2012-12-26 13:41:08

Android開發(fā)dispatchTou

2013-04-22 15:40:00

Android開發(fā)觸摸事件與點(diǎn)擊事件區(qū)別

2013-07-25 13:35:14

iOS開發(fā)學(xué)習(xí)UIScrollVietouchesBega

2011-08-02 16:28:40

iPhone Web開發(fā) 事件

2017-01-11 18:44:43

React Nativ觸摸事件Android

2013-05-14 11:08:23

AIR Android觸摸事件鼠標(biāo)事件

2011-05-11 10:28:03

2011-09-05 12:49:59

Sencha Touc事件

2013-05-21 09:54:39

Web前端

2011-09-02 15:18:49

Sencha Touc

2014-06-23 10:42:56

iOS開發(fā)UIScrollVie
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)