hyperoslo / Lightbox

:milky_way: A convenient and easy to use image viewer for your iOS app
https://www.hyper.no
Other
1.62k stars 326 forks source link

Delete image #271

Open MagicFlow29 opened 3 years ago

MagicFlow29 commented 3 years ago

Step 1 - enable delete button: LightboxConfig.DeleteButton.enabled = true

Step 2 - Delete:

Crash on: let pageView = pageViews[i] in:

  func reconfigurePagesForPreload() {
    let preloadIndicies = calculatePreloadIndicies()

    for i in 0..<initialImages.count {
      let pageView = pageViews[i]
      if preloadIndicies.contains(i) {
        if type(of: pageView.image) == LightboxImageStub.self {
          pageView.update(with: initialImages[i])
        }
      } else {
        if type(of: pageView.image) != LightboxImageStub.self {
          pageView.update(with: LightboxImageStub())
        }
      }
}

}

MagicFlow29 commented 3 years ago

Fixed by adding the following line: self.initialImages.remove(at: prevIndex)

to func headerView(_ headerView: HeaderView, didPressDeleteButton deleteButton: UIButton) {

noting the above function is also lacking a delegate

alexandrgl commented 3 years ago

This fix is already in this pull request - https://github.com/hyperoslo/Lightbox/pull/265 I think the repo maintainer just have to release new version.

3lvis commented 3 years ago

Ok! New version coming