![](/img/trans.png)
[英]How to pass indexPath row data in collectionView in Swift
[英]Cannot pass indexpath from collectionView (into LightBox package )
我安裝了這個包https://github.com/hyperoslo/Lightbox ,但是我不知道如何通過我的collectionView的索引來顯示所需的圖片,而不是第一個
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let controller = LightboxController(images: imagess)
controller.pageDelegate = self as? LightboxControllerPageDelegate
controller.dismissalDelegate = self as? LightboxControllerDismissalDelegate
controller.dynamicBackground = true
present(controller, animated: true, completion: nil)
}
在這種情況下,我可以更改圖片,但是第一個總是出現
我似乎已經閱讀了所有內容,但沒有找到這個重要細節。
如果我這樣做:
let controller = LightboxController(images: [imagess[indexPath.row]])
我只能查看具有所需索引的圖片,但不能更改圖庫中的圖片
幫助請:-)
您必須設置開始索引才能看到當前圖像。
所以試試看
let controller = LightboxController(images: imagess, startIndex:indexPath.row)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.