Skip to content

Commit

Permalink
Merge pull request #128 from beingenious/master
Browse files Browse the repository at this point in the history
Fix some storyboard incompatibility and collection view behaviours.
  • Loading branch information
steipete committed Dec 5, 2012
2 parents 6d7f8db + 9cd064c commit 0f491d2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions PSTCollectionView/PSTCollectionView.m
Expand Up @@ -341,6 +341,11 @@ - (id)dequeueReusableCellWithReuseIdentifier:(NSString *)identifier forIndexPath
cell = [cellClass new];
}
}
PSTCollectionViewLayout *layout = [self collectionViewLayout];
if ([layout isKindOfClass:[PSTCollectionViewFlowLayout class]]) {
CGSize itemSize = ((PSTCollectionViewFlowLayout *)layout).itemSize;
cell.bounds = CGRectMake(0, 0, itemSize.width, itemSize.height);
}
cell.collectionView = self;
cell.reuseIdentifier = identifier;
}
Expand Down
20 changes: 20 additions & 0 deletions PSTCollectionView/PSTCollectionViewCell.m
Expand Up @@ -121,6 +121,26 @@ - (id)initWithFrame:(CGRect)frame {
return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
if ((self = [super initWithCoder:aDecoder])) {
if ([[self subviews] count] > 0) {
_contentView = [self subviews][0];
} else {
_contentView = [[UIView alloc] initWithFrame:self.bounds];
_contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:_contentView];
}

_backgroundView = [[UIView alloc] initWithFrame:self.bounds];
_backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self insertSubview:_backgroundView belowSubview:_contentView];

_menuGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(menuGesture:)];
}
return self;
}

///////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - Public

Expand Down
2 changes: 2 additions & 0 deletions PSTCollectionView/PSTCollectionViewController.m
Expand Up @@ -52,6 +52,8 @@ - (void)loadView {
// if this is restored from IB, we don't have plain main view.
if ([self.view isKindOfClass:[PSTCollectionView class]]) {
_collectionView = (PSTCollectionView *)self.view;
self.view = [[UIView alloc] initWithFrame:self.view.bounds];
self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}

if (_collectionView.delegate == nil) _collectionView.delegate = self;
Expand Down

0 comments on commit 0f491d2

Please sign in to comment.