New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancel transition #7
Comments
What exactly do you want to happen on cancel? Revert back to the starting point? Animated or not animated? Also, could you elaborate on why you're getting the error? For example, are you starting up a new interactive transition or is the collection view doing this on its own? None of my apps rotate, so I'm not very familiar with this. |
Well when I tap on a cell to transition it to another layout but at the same time rotate the device, in which that invalidates the layout and changes the collectionview frame and then I make the call to re-layout the view, it causes the above error because its already in the middle of a transition. So what do I need it to do? I guess if a transition is in progress then stop it and continue with the next, but I am not 100% thats the right thing... |
There are only two ways to end an interactive layout transition: -[UICollectionView cancelInteractiveTransition]
-[UICollectionView finishInteractiveTransition] When you call one of these APIs, the collection view will takes over drives the progress to either 0 or 1 over a short period of time and then either revert to the original layout or install the next layout. It sounds like what you really need is the ability to stop the transition immediately. I'm not aware of any API to do this, but I needed this too and spent a couple of days this week on a workaround. If you download the cancelinplace branch, there is a new API you can try: -[UICollectionView cancelInteractiveTransitionInPlaceWithCompletion:] Its working flawlessly in my app. You would do something like this: if ([self.collectionView isInteractiveTransitionInProgress]) {
[self.collectionView cancelInteractiveTransitionInPlaceWithCompletion:^(){
// set new layout, start a new interactive transition, or whatever
}];
} The
In the UI, it should look like the collection view stopped at the point where you cancelled and it will stay that way until you replace the snapshot layout. You can start another interactive transition at this point and it will proceed from the snapshot layout to your next layout. The only caveat I know of is that it will not work with layouts that have supplementary or decorative views because the snapshot layout doesn't support that yet. |
Lovely Tim, I will give this a try for you and let you know. 👍 |
Morning, | have implemented this branch and I must say it does work very well, it no longer crashes when rotating quickly in the middle of a transition. Its an odd situation to have but I think some users will do it, if not by choice then accident! Thank you! I will do some further testing on a device today! |
Good to hear it works. I’ve pushed the code to the master branch. Tim On Apr 7, 2014, at 2:24 AM, holidaycottages notifications@github.com wrote:
|
So can we close this then? :) |
Yep. |
Hello again,
I have a situation where if i rotate my device while performing a layout transition the app errors with the following error:
the collection is already in the middle of an interactive transition
So I was wondering if there was a way I could cancel the transition if one was in progress?
The text was updated successfully, but these errors were encountered: