HamzaGhazouani/HGPlaceholders

Crash on iOS 9+ when used within UICollectionView

sasojadrovski opened this issue ยท 12 comments

Hi @HamzaGhazouani,

Good job on this awesome library! I love it!

I have noticed that a crash occurs on iOS 9.x (tested on iOS 9.3.5) if you use HGPlaceholders for a UICollectionView that has a header and/or footer. You can reproduce this issue by simply running your latest Example project (that you have pushed ~2 hours ago).

The issue is related to not updating the defaultLayout with the proper layout after the dataSource changes.

Could you please take a look?

Also, I think it is also wise to declare the PlaceholderCollectionViewCell as open, since this is already the case for PlaceholderTableViewCell. I think most devs would like to subclass it eventually.

Looking forward to your feedback. Keep up the good work!

Cheers,
Sasho

Hi @sasojadrovski, I really appreciate your feedback, thanks a lot.
I fixed the iOS 9 crash, and the PlaceholderCollectionViewCell is now open, please check the version 0.2.3
Hamza

Hi @HamzaGhazouani,

Thanks for looking into this so quickly :) I appreciate it!

I have checked, and now it crashes for the following reason:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView dataSource is not set'

Please take a look and let me know! Thanks!

Cheers,
Sasho

Strange, for me it's working fine for both iOS 9 and iOS 10

@HamzaGhazouani,

Have you tried it when the UICollectionView has data in it and that data is displayed after let's say it's fetched from an API?

Also, I am using a UICollectionView inside a ViewController. I am not using a UICollectionViewController.

The open override weak var dataSource: UICollectionViewDataSource? property observer never gets called. And I know for sure that my dataSoure and delegate outlets are connected since everything is working fine on iOS 10.

My hierarchy is the following MyCollectionView < LoadingCollectionView < CollectionView < UICollectionView. Maybe this helps.

@sasojadrovski Ok I will check that and let you know

Hey @HamzaGhazouani,

Sorry to be bothering you, I was wondering if there are any updates on this one?

Thanks in advance!

Hey @sasojadrovski, I'm working on that, I'll keep you informed :)

Hey @sasojadrovski, I think it's a UICollectionViewFlowLayout bug, I did a workaround to fix it.
To test it you could use this branch:
pod 'HGPlaceholders', :git => 'https://github.com/HamzaGhazouani/HGPlaceholders', :branch => 'FixUICollectionFlowLayoutBug'
Please update this thread if you discover anything, if it's OK I will publish the new version in the few next hours.

Thanks :)

Hey @HamzaGhazouani,

Thank you for looking into this :) I really appreciate it. I will try it out now and let you know the outcome in several minutes. Hold tight!

Cheers,
Sasho

Hey @HamzaGhazouani,

I have just checked this on a device and on the simulator (both running iOS 9.3.X and iOS 10.3.X) and everything seems to be working without any problem! ๐ŸŽ‰

I think that this branch is ready for merging and a new version should definitely be published.

I also have two additional issues and one proposal, so please let me know whether you want me to open new issues for them, or just reply to this thread.

Once again, thank you for looking into this and fixing it!

Best regards,
Sasho

Hey @sasojadrovski, Thanks for your contribution too.
The new version 0.2.4 is now available.
For the additional issues / proposals, it's better to create new issues

Thanks

You are welcome @HamzaGhazouani :)

I will open the new issues right away ๐Ÿš€