2013-07-24 47 views

回答

0

也许这就是你需要:

子类UICollectionViewController像ABCCollectionViewController

let vc = UINavigationController(rootViewController: ABCCollectionViewController()) 

然后在ABCCollectionViewControllerviewDidLoad

self.navigationItem.leftBarButtonItem = self.editButtonItem 

然后覆盖setEditting方法:

override func setEditing(_ editing: Bool, animated: Bool) { 
    super.setEditing(editing, animated: true) 

    // Use these methods to do the edit things, without test but should works 
    collectionView?.beginInteractiveMovementForItem(at: indexPath) 
    print("editting")//Do some edit thing 
    collectionView?.endInteractiveMovement() 
    collectionView.updateInteractiveMovementTargetPosition() 
    collectionView?.cancelInteractiveMovement() 
} 

然后,您可以拨打:

setEditing(true, animated: true) 
0

如果您正在编辑时改变像allowsMultipleSelection一些国家在UICollectionView

override func setEditing(_ editing: Bool, animated: Bool) { 
    super.setEditing(editing, animated: animated) 
    collectionView.allowsMultipleSelection = editing 
} 

你可以简单地添加到您的UICollectionViewCell子类:

var isEditing: Bool { 
    return (superview as! UICollectionView).allowsMultipleSelection 
}