UIPangestureRecognizer

UIPangestureRecognizer

本文介绍了UIPanGestureRecognizer没有调用End状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 UIPanGestureRecognizer 我们正在移动 UICollectionView

当我们开始拖动调用UIGestureRecognizerStateBegan 时。但是当我们仍然按住拖动单元并按下ipad中的主页按钮时, UIPanGestureRecognizer 没有调用 UIGestureRecognizerStateEnded UIGestureRecognizerStateFailed UIGestureRecognizerStateCancelled ,甚至没有调用手势方法

When we started dragging UIGestureRecognizerStateBegan is called. but when we still holds the dragging cell and presses the Home Button in ipad, the UIPanGestureRecognizer not calling UIGestureRecognizerStateEnded or UIGestureRecognizerStateFailed or UIGestureRecognizerStateCancelled, not even calling gesture method

- (void)handlePanGesture:(UIPanGestureRecognizer *)gestureRecognizer;

当我从后台打开我的应用程序时,单元格位于视图中的相同位置但无法对其执行任何操作。这是因为 UIPanGestureRecognizer 没有调用gestureStates。

When i opened my app from background the cell is at the same place in the view but am not able to perform any actions on it. this is because of UIPanGestureRecognizer not calling the gestureStates.

如何结束我的 UIPanGestureRecognizer 当用户按下主页按钮时。

How to end my UIPanGestureRecognizer when user presses the home button.

推荐答案

试试这个

    - (void)applicationWillResignActive:(UIApplication *)application {

        [self.window setUserInteractionEnabled:NO];

    }



    - (void)applicationDidBecomeActive:(UIApplication *)application {

        [self.window setUserInteractionEnabled:YES];
    }

这篇关于UIPanGestureRecognizer没有调用End状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 13:50