0

I m creating a Bubble table like message app in iOS. It require the Bouncing effect of cells while scrolling. Its working fine without TLSpringFlowLayut But, with this layout the scroll is very slow and chopy.

Also in device its taking High Memory and CPU use upto 96%

Source code : https://github.com/sibahota059/SPHChatCollectionView

Siba Prasad Hota
  • 4,779
  • 1
  • 20
  • 40

2 Answers2

1

Actually the problem is with TLSpringFlowLayout Class that you have used, Look into that class, It is adding UIAttachment Behaviour(Dynamic Behaviour) in form of Spring. So, It is obvious that you feel spring like effect while scrolling that view. Open your Xib file where you have attached Layout of the collectionView with TLSpringFlowLayout, Change It's Owner to Default, i.e. UICollectionViewFlowLayout. It is working fine now, not taking much memory or not using much CPU.

By the way, thanks for providing such a nice code, I have used that one in my Application.

Mehul Thakkar
  • 12,440
  • 10
  • 52
  • 81
1

Look in to the code in TLSpringFlowLayout.m class. Comment itself saying that it give bounce effect to collection view.

      /// The dynamic animator used to animate the collection's bounce
      @property (nonatomic, strong, readwrite) UIDynamicAnimator *dynamicAnimator;

        UIAttachmentBehavior *springBehaviour = [[UIAttachmentBehavior alloc] initWithItem:attributes attachedToAnchor:attributes.center];

        springBehaviour.length = 1.0f;
        springBehaviour.damping = 0.8f;
        springBehaviour.frequency = 1.0f;
        [self.dynamicAnimator addBehavior:springBehaviour];

UIDynamicAnimator is one type of animation in UIKit Dynamics available from ios 7.

For more see this link : How to create a UIView bounce animation?

Community
  • 1
  • 1
Bhoomi Jagani
  • 2,413
  • 18
  • 24