2017-02-17 1 views
0

나는 내 컬렉션보기에 다음 제스처 인식기를 부착 한 이동지고 :IUICollectionViewDelegateFlowLayout의 드래그 앤 드롭 기능 : 긴 누르고있는 셀 아래 셀은

public void AttachLongPressGestureRecognizer() 
     { 
      // Create a custom gesture recognizer 
      var longPressGesture = new UILongPressGestureRecognizer((gesture) => 
      { 
       // Take action based on state 
       switch (gesture.State) 
       { 
        case UIGestureRecognizerState.Began: 
         var selectedIndexPath = this.MyCollectionView.IndexPathForItemAtPoint(gesture.LocationInView(View)); 

         if (selectedIndexPath != null) 
         { 
          this.MyCollectionView.BeginInteractiveMovementForItem(selectedIndexPath); 
         } 
         break; 

        case UIGestureRecognizerState.Changed: 
         this.MyCollectionView.UpdateInteractiveMovement(gesture.LocationInView(View)); 
         break; 

        case UIGestureRecognizerState.Ended: 
         this.MyCollectionView.EndInteractiveMovement(); 
         break; 

        default: 
         this.MyCollectionView.CancelInteractiveMovement(); 
         break; 
       } 

      }); 

드래그하는 동안 및 기능이 작동하는 것 같군 드롭, 받은 selectedIndexPath가 올바르지 않습니다. 특정 셀을 길게 누르면 해당 셀 아래의 셀이 선택되어 이동합니다. 같은 세포에

[Export("collectionView:layout:sizeForItemAtIndexPath:")] 
    public CoreGraphics.CGSize GetSizeForItem(UICollectionView collectionView, UICollectionViewLayout layout, NSIndexPath indexPath) 
    { 
     var cellHeight = collectionView.Frame.Height * 0.3; 
     var cellWidth = collectionView.Frame.Width * 0.45; 
     return new CoreGraphics.CGSize(cellWidth, cellHeight); 
    } 

싱글 터치가 정확 indexPath를 반환하지만, 길게 누르면 누르고있는 셀 아래 셀의 indexPath를 반환 : 나는 화면 크기에 따라 세포의 크기를 조정하려면 다음을 사용하고 있습니다.

답변

0

다른보기의 높이가 수집 높이와 간섭하기 때문에 이런 현상이 발생합니다.