【问题标题】:Cannot pass indexpath from collectionView (into LightBox package )无法从 collectionView 传递 indexpath(进入 LightBox 包)
【发布时间】:2018-11-30 17:50:44
【问题描述】:

我安装了这个包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]])

我只能查看一张具有所需索引的图片,但无法更改图库中的图片

请帮忙:-)

【问题讨论】:

  • 你能显示'imagess'数组吗?

标签: ios swift xcode gallery


【解决方案1】:

您必须设置起始索引才能看到当前图像;

所以试试这个;

let controller = LightboxController(images: imagess, startIndex:indexPath.row)

【讨论】:

  • 谢谢)记住它
猜你喜欢
  • 2020-11-03
  • 1970-01-01
  • 1970-01-01
  • 2019-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多