【问题标题】:UIPanGestureRecognizer not calling End stateUIPanGestureRecognizer 未调用结束状态
【发布时间】:2014-03-07 10:45:42
【问题描述】:

使用UIPanGestureRecognizer,我们正在移动UICollectionView中的单元格

当我们开始拖动时,UIGestureRecognizerStateBegan 被调用。但是当我们在ipad中仍然按住拖动单元格并按下Home键时,UIPanGestureRecognizer没有调用UIGestureRecognizerStateEndedUIGestureRecognizerStateFailedUIGestureRecognizerStateCancelled,甚至没有调用手势方法

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

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

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

【问题讨论】:

  • 您是否尝试在UIGestureRecognizerStateEnded 条件下记录任何内容?
  • 是的,我试过了,它甚至没有调用 handlePanGesture: 方法
  • 能否添加手势代码?
  • - (void)handlePanGesture:(UIPanGestureRecognizer *)gestureRecognizer { switch (gestureRecognizer.state) { case UIGestureRecognizerStateBegan: case UIGestureRecognizerStateChanged: { //doing somthing here}} break; case UIGestureRecognizerStateEnded: { //calling method } default: { } break; } }

标签: ios ipad uicollectionview uipangesturerecognizer uicollectionviewlayout


【解决方案1】:

试试这个

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

        [self.window setUserInteractionEnabled:NO];

    }



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

        [self.window setUserInteractionEnabled:YES];
    }

【讨论】:

  • 触摸工作正常。能够在视图中执行其他操作,例如按下按钮。但是那个单元格仍然在那个地方而不是在collectionview列表中
  • 即使我重新加载了collectionview,但那个单元格在同一个地方并且没有添加到collectioview中
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多