tilltue / TLPhotoPicker

📷 multiple phassets picker for iOS lib. like a facebook
MIT License
1.89k stars 333 forks source link

Fixed Critical iPhone12 layout issue #312

Closed woookDev closed 3 years ago

woookDev commented 3 years ago

Problem

There is a layout issue about number of column for iPhone 12 ( In case of iPhone12, It displays 2 number of column, not standard 3 )

ScreenShot

Solution

At first, I expected calculation issue, but it seems fine and it fits with iPhone12 390 width ( 3 items(380) + 10 spacing(5,5))

Calculation Debug Result

Screen Shot 2021-06-02 at 6 11 30 PM

I think it's bug or floating point issue or something. MinimumInteritemSpacing is set to 5, and with some reason, 3 items width calculation is more than 380. As a result, collectionView layout make its column number to 2 in order to conform minimumInteritemSpacing value ( 5 ).

Screen Shot 2021-06-02 at 6 00 55 PM

And what I suggest is that column number of 3 should be preserved by changing minimumInteritemSpacing value. Because even though margin of error for item size calculation exists, it is too small to make problem if we guarantee 3 number of column even with smaller spacing So spacing 5 is not important compared to column number issue ( cuz it makes broken layout ). and we are adding 5 * count-1 for size, even smaller spacing that happens is not that small. ( it might be 4.9xxx if happens because of some kind of bug )

Image 2021-06-02 at 9 40 PM

In conclusion, I am using this in production level so I hope to fix this critical layout issue asap with this added one line unless it makes another problems. ( I checked other iphone models and many error cases, and found no issue. )

Fixed ScreenShoot