From 1f6f7dbd04a2669fff61e4cf5171d9be1d799751 Mon Sep 17 00:00:00 2001 From: David Keegan Date: Sat, 14 Dec 2013 13:30:35 -0800 Subject: [PATCH] Updated to work when created in code, also adjusted the springiness --- THSpringyCollectionView/THSpringyFlowLayout.m | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/THSpringyCollectionView/THSpringyFlowLayout.m b/THSpringyCollectionView/THSpringyFlowLayout.m index 8585aad..3f45b65 100644 --- a/THSpringyCollectionView/THSpringyFlowLayout.m +++ b/THSpringyCollectionView/THSpringyFlowLayout.m @@ -17,17 +17,29 @@ @implementation THSpringyFlowLayout { } #define kScrollRefreshThreshold 30.0f -#define kScrollResistanceCoefficient 1 / 500.0f +#define kScrollResistanceCoefficient 1 / 1000.0f -- (id)initWithCoder:(NSCoder *)aDecoder { +- (instancetype)init { + self = [super init]; + if (self){ + [self setup]; + } + return self; +} + +- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self){ - _animator = [[UIDynamicAnimator alloc] initWithCollectionViewLayout:self]; - _visibleIndexPaths = [NSMutableSet set]; + [self setup]; } return self; } +- (void)setup { + _animator = [[UIDynamicAnimator alloc] initWithCollectionViewLayout:self]; + _visibleIndexPaths = [NSMutableSet set]; +} + - (void)prepareLayout { [super prepareLayout];