From aacdf3994657c5153682391a9e3786d3d505619f Mon Sep 17 00:00:00 2001 From: Philippe Converset Date: Fri, 12 Jul 2013 18:05:25 +0200 Subject: [PATCH] Added Interface Builder compatibility. --- PSCollectionView.h | 4 ++-- PSCollectionView.m | 42 +++++++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/PSCollectionView.h b/PSCollectionView.h index df6c866..04f12e0 100644 --- a/PSCollectionView.h +++ b/PSCollectionView.h @@ -41,8 +41,8 @@ @property (nonatomic, assign, readonly) NSInteger numCols; @property (nonatomic, assign) NSInteger numColsLandscape; @property (nonatomic, assign) NSInteger numColsPortrait; -@property (nonatomic, unsafe_unretained) id collectionViewDelegate; -@property (nonatomic, unsafe_unretained) id collectionViewDataSource; +@property (nonatomic, unsafe_unretained) IBOutlet id collectionViewDelegate; +@property (nonatomic, unsafe_unretained) IBOutlet id collectionViewDataSource; #pragma mark - Public Methods diff --git a/PSCollectionView.m b/PSCollectionView.m index 2e5d405..e00f9de 100644 --- a/PSCollectionView.m +++ b/PSCollectionView.m @@ -145,28 +145,40 @@ @implementation PSCollectionView #pragma mark - Init/Memory +- (id)initWithCoder:(NSCoder *)aDecoder { + self = [super initWithCoder:aDecoder]; + if (self) { + [self setup]; + } + return self; +} + - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { - self.alwaysBounceVertical = YES; - - self.lastOffset = 0.0; - self.offsetThreshold = floorf(self.height / 4.0); - - self.colWidth = 0.0; - self.numCols = 0; - self.numColsPortrait = 0; - self.numColsLandscape = 0; - self.orientation = [UIApplication sharedApplication].statusBarOrientation; - - self.reuseableViews = [NSMutableDictionary dictionary]; - self.visibleViews = [NSMutableDictionary dictionary]; - self.viewKeysToRemove = [NSMutableArray array]; - self.indexToRectMap = [NSMutableDictionary dictionary]; + [self setup]; } return self; } +- (void)setup { + self.alwaysBounceVertical = YES; + + self.lastOffset = 0.0; + self.offsetThreshold = floorf(self.height / 4.0); + + self.colWidth = 0.0; + self.numCols = 0; + self.numColsPortrait = 0; + self.numColsLandscape = 0; + self.orientation = [UIApplication sharedApplication].statusBarOrientation; + + self.reuseableViews = [NSMutableDictionary dictionary]; + self.visibleViews = [NSMutableDictionary dictionary]; + self.viewKeysToRemove = [NSMutableArray array]; + self.indexToRectMap = [NSMutableDictionary dictionary]; +} + - (void)dealloc { // clear delegates self.delegate = nil;