gpt4 book ai didi

ios - 如何在使用 Texture 的同时实现 List CollectionViewLayout?

转载 作者:行者123 更新时间:2023-11-28 23:27:52 24 4
gpt4 key购买 nike

我在获取ListCollectionViewLayout(IGListKit 提供的库存布局)与Texture(以前称为AsyncDisplayKit)一起使用时遇到了麻烦。

这是我的 Collection View Controller :

let collectionNode: ASCollectionNode!
var refreshControl : UIRefreshControl?
var layout: ListCollectionViewLayout

var pageTitle: String?

var feedItems: [FeedItem] = [FeedItem]()

lazy var adapter: ListAdapter = {
return ListAdapter(updater: ListAdapterUpdater(), viewController: self, workingRangeSize: 1)
}()

init() {
layout = ListCollectionViewLayout.init(stickyHeaders: false, scrollDirection: .vertical, topContentInset: 0, stretchToEdge: false)
self.collectionNode = ASCollectionNode(collectionViewLayout: layout)
super.init(node: self.collectionNode)
self.adapter.setASDKCollectionNode(self.collectionNode)
self.adapter.dataSource = self
self.collectionNode.alwaysBounceVertical = true
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(refreshContent), for: .valueChanged)
self.collectionNode.view.addSubview(refreshControl!)

}

这是部分 Controller :

class HashtagSectionController: ListSectionController, ASSectionController {

weak var delegate: HashtagDataDelegate?
var pushViewDelegate: PushViewControllerDelegate?
var pushUserDelegate: PushUsernameDelegate?
var isLoading: Bool

func nodeForItem(at index: Int) -> ASCellNode {
guard let feedItem = object else { return ASCellNode() }

let node = DiscoverCellNode(post: feedItem.post, user: feedItem.user)
DispatchQueue.main.async {
node.contentNode.delegate = self
}
return node
}

override init() {
self.isLoading = false
super.init()
self.inset = UIEdgeInsets(top: 10, left: 0, bottom: 20, right: 0)
}

var object: FeedItem?

func nodeBlockForItem(at index: Int) -> ASCellNodeBlock {
guard let feedItem = object else { return {
return ASCellNode()
}
}
return {
let node = DiscoverCellNode(post: feedItem.post, user: feedItem.user)
DispatchQueue.main.async {
node.contentNode.delegate = self
}
return node
}
}

override func numberOfItems() -> Int {
return 1
}

override func didUpdate(to object: Any) {
self.object = object as? FeedItem
}

override func didSelectItem(at index: Int) {
guard let feedItem = object else { return }
pushViewDelegate?.pushViewController(post: feedItem.post, user: feedItem.user)
}

override func sizeForItem(at index: Int) -> CGSize {
return ASIGListSectionControllerMethods.sizeForItem(at: index)
//return CGSize(width: 120, height: 120)
}

override func cellForItem(at index: Int) -> UICollectionViewCell {
return ASIGListSectionControllerMethods.cellForItem(at: index, sectionController: self)
}

}

所以我不确定为什么这不起作用。我是否缺少 ListCollectionLayout 工作所需的委托(delegate)。我收到一条错误消息,指出“layoutSize 无效且不安全,无法提供给 CoreAnimation”。

最佳答案

我最终没有使用 listkit,而是决定仅使用纹理 Collection View 的比较算法。

关于ios - 如何在使用 Texture 的同时实现 List CollectionViewLayout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58107262/

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