2013-07-24 22 views

Trả lời

0

Có lẽ đây là những gì bạn cần:

Subclass UICollectionViewController như ABCCollectionViewController:

let vc = UINavigationController(rootViewController: ABCCollectionViewController()) 

Sau đó, trong viewDidLoad của ABCCollectionViewController:

self.navigationItem.leftBarButtonItem = self.editButtonItem 

Sau đó chép đè phương thức 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() 
} 

Sau đó, bạn có thể gọi:

setEditing(true, animated: true) 
0

Nếu bạn đang thay đổi một số bang như allowsMultipleSelection trong UICollectionView của bạn khi chỉnh sửa:

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

Bạn chỉ có thể thêm video này vào UICollectionViewCell phân lớp của bạn:

var isEditing: Bool { 
    return (superview as! UICollectionView).allowsMultipleSelection 
} 
Các vấn đề liên quan