gpt4 book ai didi

ios - 如何使照片多选与平移手势上的默认 iPhone 照片应用程序相同

转载 作者:行者123 更新时间:2023-12-05 06:37:30 26 4
gpt4 key购买 nike

我用过这个DoImagePickerController 但它对我不起作用。
它选择/取消选择索引上的特定项目。

See below image from DoImagePickerController

enter image description here

我需要使用 UIPanGestureRecognizer 选择/取消选择从选择索引到当前索引的所有项目。

I need to like below image sample.

enter image description here

enter image description here

如果你有任何示例应用程序/演示,请帮助我。

最佳答案

使用手势的位置跟踪选择的索引路径并循环直到选定的索引路径

    func makeSelection(on indexPath : IndexPath){
let cell = collectionView(collectionView, cellForItemAt: indexPath) as! GalleryPhotoCell

if selectionMode {
//gesture used for selecting photos
print("On selection")

cell.tapSelection ? nil : collectionView(collectionView, didSelectItemAt: indexPath)
}
else {
//gesture used for unselecting photos
print("On unselection")

cell.tapSelection ? collectionView(collectionView, didSelectItemAt: indexPath) : nil
}
}

func makeSelection(upto count : Int){
guard let start = prevIndex else {return}

if count > 0 {

for item in 0 ..< count {
let index = IndexPath(item: start.item + item + 1, section: start.section)
makeSelection(on: index)

}
}
else {
for item in 0 ..< abs(count){
let index = IndexPath(item: start.item - item - 1, section: start.section)
makeSelection(on: index)
}
}
}

关于ios - 如何使照片多选与平移手势上的默认 iPhone 照片应用程序相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47881183/

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