KelvinJin / AnimatedCollectionViewLayout

A UICollectionViewLayout subclass that adds custom transitions/animations to the UICollectionView without effecting your existing code.
MIT License
4.7k stars 347 forks source link

CubeAttributesAnimator screen display is strange. #54

Closed fumiyasac closed 4 years ago

fumiyasac commented 4 years ago

Description

Hi,

I use this library and choose CubeAttributesAnimator in my iOS app, but screen display is strange. When I implement photo gallery with full screen, I can only see half photo. I think it seems to be caused by a bug of internal animation logics.

thanks :)

Environments

AnimatedCollectionViewLayout Version: 1.0.0 Xcode version: 11.1 Swift version: 5.1 Platform(s) running AnimatedCollectionViewLayout: iOS macOS version running Xcode: 10.15.1

ScreenShots

Strange Finished Pagination:

Strange_Finished_Pagination

Expected Collect State Finished Pagination:

Expected_Collect_State_Finished_Pagination

KelvinJin commented 4 years ago

Hey! Sorry for the late reply. I'll need more information to help you resolve this issue. Can you extract a sample out from your app that can reproduce this issue?

If it's too hard, do you mind sharing some of your code snippet? The most important parts are how you're adding images/texts to the UICollectionViewCell (if it's in code, do you add them to the cell itself or the cell's contentView), how you're defining the size/padding (in a delegate or using itemSize property) and how the xib file look like if you're using IB.

fumiyasac commented 4 years ago

@KelvinJin Thank you for reply. Code snippet is below.

Code Snippet

【Initialize CubeAttributesAnimator】

let layout = AnimatedCollectionViewLayout()
layout.animator = CubeAttributesAnimator()
layout.scrollDirection = .horizontal
collectionView.collectionViewLayout = layout

【UICollectionViewDelegateFlowLayout】

extension GalleryViewController: UICollectionViewDelegateFlowLayout {

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
    }

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
        return 0
    }

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
        return 0
    }

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
        return .zero
    }
}

Repository

My sample repository is below. Now I use RotateInOutAttributesAnimator, but it occurs when it changes CubeAttributesAnimator.

https://github.com/fumiyasac/2nd_ios_ui_recipe_showcase/blob/master/03_PurchasePresentContents/PurchasePresentContents/PurchasePresentContents/ViewController/Gallery/GalleryViewController.swift

KelvinJin commented 4 years ago

Hey @fumiyasac! Thanks for the repository. I was able to reproduce the issue. It's very strange that the demo works under iOS 13 but not your app. I'm not 100% sure but I think it's happening when UIKit reset the position of the content view but not the anchor point.

I've released a new version 1.0.1 and it should be available on CocoaPods. Can you please try that version and let me know if it works? Thanks!

fumiyasac commented 4 years ago

@KelvinJin Thank you for new version 1.0.1. I tried new version, but it still not working when I used CubeAttributesAnimator. If you need, please refer to testing repository below. (There are many Japanese comments in the code, so I am sorry that it is difficult to read.)

Testing Repository:

https://github.com/fumiyasac/2nd_ios_ui_recipe_showcase/commit/2c9236b53bb9ea9896074a71d194e00a05a6396a

KelvinJin commented 4 years ago

@fumiyasac Hmm, I tested your app and it's working correctly for me on iOS 13. I tested on both a simulator and a device. Can you double check you cleaned the cache?

Check the following Gif. (I compressed it so it looks colourless) cubeanimator

fumiyasac commented 4 years ago

@KelvinJin Thank you for handling it quickly!! I tried to execute cache clear $ rm -rf /Users/MyMacBookPro/Library/Developer/Xcode/DerivedData/, it works collect.

KelvinJin commented 4 years ago

Good to know! Thanks for submitting and helping with the diagnosis! I'll close the issue.

nikinci commented 3 years ago

I am facing with same problem below ios 14. With 1.0.1 version it works below 14 but dont work with iOS 14 AnimatedCollectionViewLayout Version: 1.1.0 Xcode version: 12.2 Swift version: 5 Platform(s) running AnimatedCollectionViewLayout: iOS macOS version running Xcode: 11.0.1