zoukankan      html  css  js  c++  java
  • UITapGestureRecognizer响应顺序是怎么样的

    一个scrollview上有几个按钮
    在scrollview上add 了一个单击事件

        singletap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
        [singletap setNumberOfTapsRequired:1];
       [scrollview addGestureRecognizer:singletap];
    这样点击按钮,不会响应按钮的事件,直接跳到handleSingleTap去了?
    单击事件不是应该先被直接单击的subview处理,如果没有处理才提交到supview处理嘛?
    怎么才能让按钮响应单击事件?


    使用
    UIGestureRecognizerDelegate的一个方法判断点击的是哪个view,确定是否响应事件。
        singletap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
        [singletap setNumberOfTapsRequired:1];
        singletap.delegate = self;
       [scrollview addGestureRecognizer:singletap];



    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
        if(touch.view != scrollview){
            return NO;
        }else
            return YES;

  • 相关阅读:
    Python Virtualenv 虚拟环境
    二叉树的左视图和右视图
    Vxlan简介
    2、程序的基本结构
    chef cookbook 实战
    eclipse 搭建ruby环境
    linux 安装软件出现/tmp 磁盘不足时 解决方案
    Python 可变对象与不可变对象
    Chapter 4-5
    Chapter 3
  • 原文地址:https://www.cnblogs.com/xitang/p/3979110.html
Copyright © 2011-2022 走看看