Successful Swipe in UITextView?

后端 未结 6 998
暖寄归人
暖寄归人 2020-12-10 08:45

Has anyone been able to implement a successful swipe gesture on a UITableView? By default this is not possible due to the scrolling nature of the control. I\'ve tried subcla

6条回答
  •  -上瘾入骨i
    2020-12-10 09:06

    An even better solution, I have found, is to simply pass touches back to the superview:

    @interface SwipeableTextView : UITextView {
    }
    
    @end
    
    @implementation SwipeableTextView
    
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        [super touchesBegan:touches withEvent:event];
    
        [self.superview touchesBegan:touches withEvent:event];
    
    }
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        [super touchesMoved:touches withEvent:event];
    
        [self.superview touchesMoved:touches withEvent:event];
    }
    
    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        [super touchesEnded:touches withEvent:event];
    
        [self.superview touchesEnded:touches withEvent:event];
    } 
    
    @end
    

提交回复
热议问题