Closed myeyesareblind closed 9 years ago
I have the same issue, but your fix is not helping. I am setting this layout in Storyboard and then changing it dynamically and with your fix its still crashing.
Do you have a demo project that demonstrate this? If you have I can review it.
If you add to your example something like
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.collectionView.collectionViewLayout = [LXReorderableCollectionViewFlowLayout new];
self.collectionView.collectionViewLayout = [LXReorderableCollectionViewFlowLayout new];
}
It will crash then
Noted. Thanks. Will give it a try and get back to you guys.
@bartg , thank you, my first commit didn't fix the issue. The problem is that in dealloc, collection view is already nil, so the gestures still exists.
I won't do that, feel free to contribute.
@bartg That was what I was thinking as well.
I was thinking of the following changes but some of it I'm currently not confident enough about them. I'm tagging LOW, MED, HIGH as an indication of my confidence level of each point.
weak
, from strong
.weak
in nature, and the change might cause unexpected behaviour. So I'm letting it slip.-[LXReorderableCollectionViewFlowLayout tearDownCollectionView]
which wraps @bartg solution but with some if guards. (I prefer to be extra caution) It should be the opposite of -[LXReorderableCollectionViewFlowLayout setupCollectionView]
.-[LXReorderableCollectionViewFlowLayout tearDownCollectionView]
be called in both dealloc
and KVO of collectionView
properties.@lxcid I like 2-3, this way you are making it obvious that there is some important code to be run on dealloc.
Thanks @myeyesareblind, didn't realise its your changes. I have pull from your repro and work on top of your changes. :)
Could you help me review if this look good? My initial test seems to work. Let me know if you find any quirkiness. If all is well I'll merge to master and release a tag.
/cc @bartg
It's good
Thanks for the help! Its merged!
I got a weird crash when I changed collectionViewFlowLayout dynamically. Current version leaves gestures alive, so when the collectionView is tapped, gestureRecognizer will send message to zombie.