uias / Pageboy

📖 A simple, highly informative page view controller
MIT License
1.99k stars 154 forks source link

Not possible to remove the last page #208

Closed Mattijah closed 5 years ago

Mattijah commented 5 years ago

If there is only 1 page left, calling deletePage seems to have no effect at all. The view controller will still stay in, displayed. Is this an expected behaviour or a bug?

On top of that, if I pass .scrollToUpdate the viewController(for pageboyViewController:) will be called with an index of -1. Again, doesn't matter if I return nil or a blank VC. Nothing changes. *It should not be called with -1.

Calling reloadData doesn't help either.

Version: 3.1.0

msaps commented 5 years ago

@Mattijah will check it out 👍

Coeur commented 5 years ago

@Mattijah, currently on master branch, I don't have your behavior; when I delete the last page, I get a Fatal error: Index out of range. And this is partially fixed on the branch https://github.com/uias/Pageboy/tree/feature/insertion-fix (still more to do)

Mattijah commented 5 years ago

@Coeur I use Pageboy as a part of Tabman. I have just tried to delete the last page again, there is no error and the application continues running normally. The page (ViewController) is still displayed and present in the hierarchy. pageCount returns the same number (1) after deletePage(at: 0, then: .doNothing) was executed.

Coeur commented 5 years ago

My test was using the example app, which uses deletePage(at: index): https://github.com/uias/Pageboy/blob/master/Example/Pageboy-Example/PageViewController+Bulletins.swift#L59

Well, anyway, crash or not, it's being acknowledged that there is a problem to solve there.

msaps commented 5 years ago

@Mattijah @Coeur fixed in 3.2.2 🍾