I'm using UIPageViewController with transition style swipe, to implement a photo gallery. As the user swipes through photos, she can delete an individual photo, in which case the gallery goes to the next photo, along with an animation. This works as expected.
If the last photo is deleted, we go to the photo before the deleted one. This also works as expected, but the animation is wrong — it looks as if we're going to the next photo.
My code is:
let photo = (viewControllers!.first as! SinglePhotoController).photo
var nextPhoto = Photo.after(photo: photo)
if nextPhoto == nil {
nextPhoto = Photo.before(photo: photo)
print("You deleted the last photo, so showing previous photo")
}
photo.delete {
let nextController = self.makeController(photo: nextPhoto!)
self.setViewControllers([nextController], direction: .forward, animated: true)
}
photo.delete() is a method that deletes the photo and invokes the callback on the main thread.
How do I invoke setViewControllers() with a different animation?
This is on iOS 10.