ios – Modifying mode animation does not work properly in UICollectionViewListCell with XIB


Utilizing UICollectionViewListCell with UIListContentConfiguration.valueCell, permits us to realize modifying mode animation in UICollectionView

non-public typealias CellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, Guidelines>

non-public func initCellRegistration() {
    cellRegistration = UICollectionView.CellRegistration(
        handler: { (cell: UICollectionViewListCell, _, character: Guidelines) in
            var content material = UIListContentConfiguration.valueCell()
            content material.textual content = character.textual content
            cell.contentConfiguration = content material
            
            var equipment: [UICellAccessory] = [
                .reorder(displayed: .whenEditing),
                .delete(displayed: .whenEditing, actionHandler: { [weak self] in
                })
            ]
            
            cell.equipment = equipment
        }
    )
}

Utilizing UICollectionViewListCell with UIListContentConfiguration.valueCell

enter image description here


Nevertheless, such a strategy has a shortcoming.

I’m not capable of outline my very own customized UI parts.

I wish to have a UIButton, and a UITextView.

I tries to make use of the next methodology.

non-public typealias CellRegistration = UICollectionView.CellRegistration<ChecklistCell, Guidelines>

non-public func initCellRegistration() {
    self.cellRegistration = UICollectionView.CellRegistration<ChecklistCell, Guidelines>(cellNib: ChecklistCell.getUINib()) { cell, indexPath, merchandise in
        cell.replace(merchandise)
        
        var equipment: [UICellAccessory] = [
            .reorder(displayed: .whenEditing),
            .delete(displayed: .whenEditing, actionHandler: { [weak self] in
            })
        ]
        
        cell.equipment = equipment
    }
}

class ChecklistCell: UICollectionViewListCell {

    @IBOutlet weak var textView: UITextView!
    
    override func awakeFromNib() {
        tremendous.awakeFromNib()
        // Initialization code
    }

    func replace(_ guidelines: Guidelines) {
        textView.textual content = guidelines.textual content
    }

    static func getUINib() -> UINib {
        return UINib(nibName: String(describing: self), bundle: nil)
    }
}

It nearly work. However, the customized UI parts shouldn’t be being “pushed”, when the delete/ reordering equipment seem. Please seek advice from the next video.

Utilizing UICollectionViewListCell with XIB

enter image description here

Do you’ve any concept how I can resolve such a limitation? Thanks.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles