zoukankan      html  css  js  c++  java
  • touches,motion触摸事件响应

    //触摸事件响应需要重写方法

    1
    // 触摸时触发该方法(消息发送) 2 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ 3 UITouch *touch = [touches anyObject]; 4 CGPoint point = [touch locationInView:self.rootView.touchView];//locationInView:得到当前点击下在指定视图中位置的坐标 5 NSLog(@"触摸开始:%.2f,%.2f",point.x,point.y); 6 } 7 //但触摸移动时触发该事件 8 - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ 9 10 UITouch *touch = [touches anyObject]; 11 CGPoint point1 = [touch locationInView:self.rootView.touchView]; 12 CGPoint point2 = [touch previousLocationInView:self.rootView.touchView];//previouslocationInView:得到当前点的前一个点在指定视图中位置的坐标 13 } 14 // 触摸结束时触发该方法(消息发送) 15 - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ 16 NSLog(@"触摸结束"); 17 } 18 //发生其他情况,如来电话或意外退出时,执行该方法 19 - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ 20 21 }
    //手机摇一摇实现要重写方法

    1
    //开始时调用 2 - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ 3 NSLog(@"摇一摇开始"); 4 } 5 //结束时调用 6 - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{ 7 NSLog(@"摇一摇结束"); 8 } 9 //意外情况调用 10 - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event{ 11 NSLog(@"意外退出"); 12 }
  • 相关阅读:
    js获取url参数值[转]
    jQuery.validate 中文API【转】
    tinyMCE使用详解
    使IE6下PNG背景透明的七种方法任你选
    MVC3 上传文件【转】
    兼容google浏览器的CSS代码
    MVC3 输出HTML标签
    正则表达式 非常实用
    silverlight 压缩算法
    silverlight 4调试离线应用
  • 原文地址:https://www.cnblogs.com/Ager/p/4883873.html
Copyright © 2011-2022 走看看