Handling touches inside UIWebview

前端 未结 10 2080
感情败类
感情败类 2020-11-30 22:46

I have created a subclass of UIWebView , and have implemented the touchesBegan, touchesMoved and touchesEnded methods.

10条回答
  •  执笔经年
    2020-11-30 23:49

    Do you mean your sub-classed implementation is not called when touchesBegan, touchesMoved and touchesEnded are called?

    It sounds like a problem with how you've created an instance of the object. More details are required I think.

    (taken form comments)

    Header File

    #import  
    
    @interface MyWebView : UIWebView { } @end 
    

    Implementation File

    #import "MyWebView.h" 
    
    @implementation MyWebView 
    
    - (id)initWithFrame:(CGRect)frame { 
        if (self = [super initWithFrame:frame]) { } return self; 
    } 
    
    - (void)drawRect:(CGRect)rect { 
        NSLog(@"MyWebView is loaded"); 
    } 
    
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
       NSLog(@"touches began"); 
    } 
    
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
        NSLog(@"Touches ended");     
    } 
    
    - (void)dealloc { 
       [super dealloc]; 
    } 
    
    @end
    

提交回复
热议问题