gpt4 book ai didi

swift - 以编程方式增加 indexPath

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

如何以编程方式增加 indexPath 类型的 var?例如,当前的 indexPath 是 [0, 44],我希望在执行特定操作后 indexPath 是 [0,45]?

最佳答案

由于您正在使用 Collection View ,因此您似乎想要增加 item 属性。

someIndexPath.item += 1

如果需要,您还可以基于旧的创建一个新的 IndexPath:

let newIndexPath = IndexPath(item: oldIndexPath.item + 1, section: oldIndexPath.section)

关于swift - 以编程方式增加 indexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53195253/

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