gpt4 book ai didi

ios - 在 Interface Builder 中为 Collection View Cell 设置 Reuse Identifier 有什么意义?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:17:11 25 4
gpt4 key购买 nike

Collection Reusable Views,包括 Collection View Cells(它是一个子类),在 Interface Builder 中有一个名为“Identifier”的字段,提示为“Reuse Identifier”。

但是,您通常使用 –registerNib:forCellWithReuseIdentifier:–registerNib:forSupplementaryViewOfKind:withReuseIdentifier:UICollectionView 注册它来使用它> 方法,您还可以在其中指定重用标识符。

那么在 Interface Builder 中设置一个有什么意义呢?设置与否似乎没有什么区别。

最佳答案

如果您从 Storyboard中隐式加载 Collection View ,您只需要做

UICollectionView *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionViewCell" forIndexPath:indexPath];

获取单元格。您不需要调用 registerNib:。这仅在您设置重用标识符时有效。

关于ios - 在 Interface Builder 中为 Collection View Cell 设置 Reuse Identifier 有什么意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20412571/

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