zoukankan      html  css  js  c++  java
  • 如何判断touch到子视图或离开视图

    http://gaohaijun.blog.163.com/blog/static/176698271201151505129253/

    这是在ios开发中常见的功能。即,touch移动事件,是移动到当前视图的子视图中,还是移动到当前视图以外了。

    办法是,继承UIView,覆盖touchesMoved方法:

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 
        UITouch *touch=[touches anyObject]; 
        if (![self pointInside:[touch locationInView:self] withEvent:nil]) { 
            NSLog(@"touches moved outside the view"); 
        }else { 
            UIView *hitView=[self hitTest:[[touches anyObject] locationInView:self] withEvent:nil]; 
            if (hitView==self) { 
                NSLog(@"touches moved in the view"); 
            }else{ 
                NSLog(@"touches moved in the subview"); 
            } 
        } 
    }

     
     
     
     
     
  • 相关阅读:
    语法树,短语,直接短语,句柄
    理解文法和语法
    了解编译原理
    实习日记7.20
    实习日记7.19
    实习日记7.18
    实习日记7.15
    实习日记7.13-7.14
    实习日记7.12
    实习日记7.11
  • 原文地址:https://www.cnblogs.com/celestial/p/2544176.html
Copyright © 2011-2022 走看看