【问题标题】:Velocity in View.视图中的速度。
【发布时间】:2014-04-02 16:15:01
【问题描述】:

我正在开发类似于UIPageController 的自定义ViewController

我使用一个完整的子视图,我在其中添加了一个 PanGesture。如果翻译或速度足够高以更改页面,我想更改页面。我想知道是否有人建立了在 iPhone 和 iPad 上滑动时发现的速度标准值列表。

【问题讨论】:

    标签: ios uiviewcontroller uigesturerecognizer velocity uipangesturerecognizer


    【解决方案1】:
    #define kPanTranslationXForSwipe 15.0f
    
    //...
    - (void)handlePanGestureOnOverlayView:(UIPanGestureRecognizer *)pan
    {
        CGPoint translation = [pan translationInView:pan.view];
    
        /********************************
         * Checking for swipe detection
         ********************************/
        if (abs(translation.x) > kPanTranslationXForSwipe) {
            // check swipe direction
            if (translation.x > 0) { //right
              //Do something for right swipe
    
              return;
            } else { //left
              //Do something for left swipe
    
              return;
            }
        }
        /********************************/
    
        // Do something for pan 
        //...
    }
    

    【讨论】:

    • 我的问题不是关于代码,而是关于你的 kPanTranslationXForSwipe 的标准值,这对 iPhone 和 iPad 有意义(分辨率不同,因此阈值也不同)。根据我的情况,水平和垂直滑动也应该不同
    • 对了,你刚才提到了[pan translationInView:pan.view];但是 [pan velocityInView:pan.view];也应该用来做最好的交互
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-20
    • 2017-04-24
    相关资源
    最近更新 更多