gpt4 book ai didi

swift - UICollectionView 什么时候完成加载?

转载 作者:IT王子 更新时间:2023-10-29 05:21:02 25 4
gpt4 key购买 nike

How do I know that the UICollectionView has been loaded completely?我试图在 Swift 中重现这个解决方案,但我在阅读 Obj-C 时遇到了问题。有人可以帮忙吗?

最佳答案

SWIFT 3:@libec 的回答版本

override func viewDidLoad() {
super.viewDidLoad()
collectionView.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.old, context: nil)
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
collectionView.removeObserver(self, forKeyPath: "contentSize")
}

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if let observedObject = object as? UICollectionView, observedObject == collectionView {
print("done loading collectionView")
}
}

关于swift - UICollectionView 什么时候完成加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31908133/

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