Fix crash when using 2.3.1 in UICollectionViews or similar #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In certain cases (collection views just being one of them), view initialization takes place within a
layoutSubviews
call.-[UIView layoutSubviews] does some evaluation of constraints and seems to keep its own references to them. Therefore it is possible, that constraints of the placeholderView are being used, after we're done with view initialization.
As the
placeholderView
gets replaced it would previously be deallocated immediately. As NSLayoutConstraints only keep weak references on their items this lead to a dangling pointer onthe
firstItem
property.This change asynchronously dispatches a block enclosing the
placeholderView
. This defers the deallocation of theplaceholderView
until the end of the current runloop cycle and allows the current layoutSubviews call to go through before.Based on the suggestion by @fuaiyi
Fixes #29
Might fix other issues regarding the iOS 10 Update.
@sunnyxx Thanks for the English readme and in-code documentation.
Note to other users of the framework: Please keep GitHub communication (issues and comments) for open-source projects in English. English is not my mother tongue either, but using a common language makes collaboration a lot easier.