Modifica

Condividi tramite


UICollectionViewController.MoveItem Method

Definition

Moves the cell at sourceIndexPath to destinationIndexPath.

[Foundation.Export("collectionView:moveItemAtIndexPath:toIndexPath:")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, null)]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual void MoveItem (UIKit.UICollectionView collectionView, Foundation.NSIndexPath sourceIndexPath, Foundation.NSIndexPath destinationIndexPath);
abstract member MoveItem : UIKit.UICollectionView * Foundation.NSIndexPath * Foundation.NSIndexPath -> unit
override this.MoveItem : UIKit.UICollectionView * Foundation.NSIndexPath * Foundation.NSIndexPath -> unit

Parameters

collectionView
UICollectionView

The T:UKit.UICollectionView in which the move is being attempted.

sourceIndexPath
NSIndexPath

The NSIndexPath at which the cell began the move.

destinationIndexPath
NSIndexPath

The NSIndexPath at which the cell has been moved.

Attributes

Remarks

Developers should override this method if they wish the UICollectionView to support reordering its cells. This method should adjust the T:UIKit.UIViewControllerDataSource to reflect the new ordering. For instance, if the data were stored in a simple array, developers can simply swap the values from the source and destination cells:

public override void MoveItem (UICollectionView collectionView, NSIndexPath sourceIndexPath, NSIndexPath destinationIndexPath)
{
  //numbers is an array data structure for the UICollectionViewData
	var tmp = numbers [(int)sourceIndexPath.Item];
	numbers [(int)sourceIndexPath.Item] = numbers [(int)destinationIndexPath.Item];
	numbers [(int)destinationIndexPath.Item] = tmp;
}           

Applies to