[Swift] Why FlowLayout should use Delegate instead of instance

There is an implementation using CollectionView in practice, At that time using a FlowLayout instance Since there was a difference in drawing for each terminal and it became a hard code, I wrote this article.

Why you should use Delegate Flow Layout as much as possible

This involves a life cycle. https://qiita.com/Sossiii/items/4ffcbc07d9ccecab6420

When using an instance, regardless of life cycle The drawing process can be executed at the timing of the implementer. If you do this at the wrong time, It means that the drawing does not go well.

Due to this, on iPhone Max series and SE1 Layout collapse (not reflected according to logic) occurs, It will be corrected by hard code.

If the life cycle is the cause and can be solved by DelegateFlowLayout Now that I know, the hard code has been resolved.

Conclusion

FlowLayout is not an instance Safe to use DelegateFlowLayout

Recommended Posts

[Swift] Why FlowLayout should use Delegate instead of instance
[Java] Why use StringUtils.isEmpty () instead of String.isEmpty ()
Why use setters/getters instead of public/private in Java
Use enum instead of int constant
[Swift] Vaguely grasp the flow of Delegate
Item 36: Use EnumSet instead of bit fields
Item 37: Use EnumMap instead of ordinal indexing
[Java] use Optional instead of if (hoge! = null) {...}