zoukankan      html  css  js  c++  java
  • 关于UIScrollView不能响应UITouch事件的解决办法

    原因是:UIViewtouch事件被UIScrollView捕获了。

    解决办法:让UIScrollView将事件传递过去。于是最简单的解决办法就是加一个UIScrollViewcategory。这样每个用到UIScrollView的地方只要导入这个category就可以直接响应相关的touch事件了。

    类似问题:在论坛看见很多人说UIImageView也没办法响应,不过我想解决办法和原因都是一样的。

    #import "UIScrollView+UITouch.h"
    
    @implementation UIScrollView (UITouch)
    
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
      [[self nextResponder] touchesBegan:touches withEvent:event];
      [super touchesBegan:touches withEvent:event];
    }
    
    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
      [[self nextResponder] touchesMoved:touches withEvent:event];
      [super touchesMoved:touches withEvent:event];
    }
    
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
      [[self nextResponder] touchesEnded:touches withEvent:event];
      [super touchesEnded:touches withEvent:event];
    }
    
    @end
    
  • 相关阅读:
    git 镜像地址
    IntelliJ IDEA 2019 控制台中文乱码问题
    LINUX配置本地YUM源
    动态添加js的代码
    Java 多线程
    Java I/O系统
    Java 中的容器 Collection 和 Map
    Java 数组
    javaweb的四大作用域
    三层 转自http://git.oschina.net/tzhsweet/superui
  • 原文地址:https://www.cnblogs.com/jyking/p/6737265.html
Copyright © 2011-2022 走看看