zoukankan      html  css  js  c++  java
  • iOS手势学习UIGestureRecognizer & cocos2d 手势推荐

    iOS手势学习UIGestureRecognizer & cocos2d 手势推荐

    手势识别类型:

    UILongPressGestureRecognizer   // 长按
    UIPanGestureRecognizer      // 慢速拖动
    UIPinchGestureRecognizer     // 两指向內或向外拨动
    UIRotationGestureRecognizer     // 旋转
    UISwipeGestureRecognizer      // 快速滑动
    UITapGestureRecognizer       // 点击

    手势协议:

    复制代码
    @protocol UIGestureRecognizerDelegate <NSObject>
    @optional
    // called when a gesture recognizer attempts to transition out of UIGestureRecognizerStatePossible. returning NO causes it to transition to UIGestureRecognizerStateFailed
    - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;
    
    // called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other
    // return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)
    //
    // note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
    
    // called before touchesBegan:withEvent: is called on the gesture recognizer for a new touch. return NO to prevent the gesture recognizer from seeing this touch
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
    
    @end
    复制代码

    手势优先级:

    复制代码
    // create a relationship with another gesture recognizer that will prevent this gesture's actions from being called until otherGestureRecognizer transitions to UIGestureRecognizerStateFailed
    // if otherGestureRecognizer transitions to UIGestureRecognizerStateRecognized or UIGestureRecognizerStateBegan then this recognizer will instead transition to UIGestureRecognizerStateFailed
    // example usage: a single tap may require a double tap to fail
    - (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer;
    复制代码

    各种手势Demo:UIGestureRecognizer学习笔记

    cocos2d手势库推荐:SFGestureRecognizers  github链接

  • 相关阅读:
    meta标签总结
    基本类型String的原生方法详解
    对JSON的增删查改
    百分比宽度div如何水平居中
    【转】Chrome 控制台console的用法(提高js调试能力)
    css textarea固定大小滚动条自动
    【转】前端必读:浏览器内部工作原理
    git clone 远程分支
    http-server 使用介绍
    js 全选/取消
  • 原文地址:https://www.cnblogs.com/LiLihongqiang/p/5844108.html
Copyright © 2011-2022 走看看