Comments (4)
Have you tried invalidating the destination layout before transitioning?
Tim
On Sep 30, 2014, at 2:19 PM, Charles Scalesse [email protected] wrote:
Hey Tim, thanks for creating this. It was working well for me when I had only one section in my collection view, but now with multiple sections I'm experiencing a crash during transitionToCollectionViewLayout:duration:easing:completion: that I wasn't experiencing with the stock setCollectionViewLayout:animated:completion: method.
The setup:
I have a collection view that supports a transition between a 1-wide grid layout and a 4-wide grid layout. The cells in the collection view are sectioned by month (Sept 2014, August 2014, ...) and the content is paginated such that when the user scrolls to the bottom new content is requested from my API and appended to my dataSource (currently just calling reloadData instead of performing any insertion updates).Steps:
- Start with a 1-wide grid. Transition to a 4-wide grid. Technically there's still only 1 section at this point, because we're still in the first month of data.
- Scroll down a few pages in the 4-wide grid until we've reached the next section.
- Attempt to transition back to the 1-wide grid results in a crash at this line:
UICollectionViewLayoutAttributes *toPose = reverse
? [self.currentLayout layoutAttributesForItemAtIndexPath:indexPath]
: [self.nextLayout layoutAttributesForItemAtIndexPath:indexPath];
Because self.nextLayout's layoutAttributesForItemAtIndexPath:indexPath returns nil when the section index > 0. The error is:Uncaught exception: *** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]
It appears that when I transition from the 1-wide layout, there's only one section in existence. Then, after scrolling the 4-wide layout, there's multiple sections. Attempting to go back to the 1-wide layout, the crash occurs.
If I scroll through many sections while in the 1-wide layout, and then scroll back up, I'm free to transition between layouts since the number of sections in the 1-wide layout is in sync with the number of sections in the 4-wide layout.
Any idea how to fix this? I'd very much like to continue using your library.
Thanks!
—
Reply to this email directly or view it on GitHub #13.
from tllayouttransitioning.
I swear that was the very first thing I tried. Honestly. Ugh.
Thanks.
from tllayouttransitioning.
Hah. Glad it worked.
Tim
On Sep 30, 2014, at 2:47 PM, Charles Scalesse [email protected] wrote:
I swear that was the very first thing I tried. Honestly. Ugh.
Thanks.
—
Reply to this email directly or view it on GitHub #13 (comment).
from tllayouttransitioning.
Just in case anyone else has this issue, I thought I'd follow up with some additional info.
There was actually 2 separate problems here resulting the same crash, hence why I thought invalidateLayout
originally didn't solve the problem. The first was what is described above and is fixed by invalidating the destination layout. The second occurred when the number of sections changed during the course of the transition itself. In my case this was also pretty common, because the transition from the 1-wide grid to the 4-wide grid frequently triggers an API request for the next page, and if the response comes back before the transition completes, it'll crash with the same error.
from tllayouttransitioning.
Related Issues (20)
- -[UICollectionViewTransitionLayout setToContentOffset:]: unrecognized selector HOT 3
- catch a error what it means? HOT 2
- Resize example crashes when double clicking a cell HOT 1
- Podfile configuration for example HOT 2
- pinch again during animation HOT 2
- indexPath on Resize demo HOT 1
- Exception during pinch gesture handling. HOT 1
- Jarring snap at end of interactive transition. HOT 3
- UICollectionView not centering transition in iOS 9, worked fine in iOS 8. HOT 20
- Disable bounce effect in interactive transitions HOT 4
- Public Headers HOT 1
- Not usable with Swift due to problem with AHEasing.
- No source files in framework target. HOT 1
- Getting crash in pinch gesture after pagination HOT 4
- Examples not building HOT 5
- Resize / scale question HOT 2
- Memory leak HOT 12
- Cancel transition HOT 8
- layout transition for supplementary views HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tllayouttransitioning.