使用 UIPanGestureRecognizer
我们正在移动 UICollectionView
中的单元格
当我们开始拖动时 UIGestureRecognizerStateBegan
被调用。但是当我们仍然按住拖动单元格并按下 ipad 中的主页按钮时,UIPanGestureRecognizer
不调用 UIGestureRecognizerStateEnded
或 UIGestureRecognizerStateFailed
或 UIGestureRecognizerStateCancelled
,甚至不调用手势方法
- (void)handlePanGesture:(UIPanGestureRecognizer *)gestureRecognizer;
当我从后台打开我的应用程序时,单元格位于 View 中的同一位置,但无法对其执行任何操作。这是因为 UIPanGestureRecognizer
没有调用 gestureStates。
如何在用户按下主页按钮时结束我的 UIPanGestureRecognizer
。
最佳答案
试试这个
- (void)applicationWillResignActive:(UIApplication *)application {
[self.window setUserInteractionEnabled:NO];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[self.window setUserInteractionEnabled:YES];
}
关于ios - UIPanGestureRecognizer 不调用结束状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22247920/