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"); 
            } 
        } 
    }

     
     
     
     
     
  • 相关阅读:
    浮动 float
    display属性和特性
    盒子阴影
    内边距
    外边距
    边框
    网页背景
    猴子补丁
    设计模式创造者模式--python
    Go语言:validator库对请求参数校验
  • 原文地址:https://www.cnblogs.com/celestial/p/2544176.html
Copyright © 2011-2022 走看看