gpt4 book ai didi

ios - 缺少编辑属性和setEditing :animated: in UICollectionViewCell

转载 作者:技术小花猫 更新时间:2023-10-29 10:54:20 27 4
gpt4 key购买 nike

与 UITableViewCell 不同,UICollectionViewCell 缺少 setEditing:animated:editing 属性。

这是设计使然吗? Apple 是否强制执行其他最佳实践来处理 UICollectionView 及其单元格中的编辑?

最佳答案

也许这就是您所需要的:

ABCCollectionViewController 这样的 UICollectionViewController 子类:

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)

关于ios - 缺少编辑属性和setEditing :animated: in UICollectionViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17829252/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com