2013-07-24 76 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 
}