Browse files

Fix for incorrect loading layout from nib

  • Loading branch information...
1 parent 45c19b8 commit 11ab111e9c658d8c52b4cc70820b3e2b54f07890 @fduch2k fduch2k committed Mar 7, 2013
View
21 PSTCollectionView/PSTCollectionView.m
@@ -116,7 +116,6 @@ @interface PSTCollectionView() <UIScrollViewDelegate> {
// (We need to keep the total class size equal to the UICollectionView variant)
@interface PSTCollectionViewExt : NSObject
@property (nonatomic, unsafe_unretained) id<PSTCollectionViewDelegate> collectionViewDelegate;
-@property (nonatomic, strong) id nibObserverToken;
@property (nonatomic, strong) PSTCollectionViewLayout *nibLayout;
@property (nonatomic, strong) NSDictionary *nibCellsExternalObjects;
@property (nonatomic, strong) NSDictionary *supplementaryViewsExternalObjects;
@@ -176,11 +175,7 @@ - (id)initWithCoder:(NSCoder *)inCoder {
PSTCollectionViewCommonSetup(self);
- // add observer for nib deserialization.
- id nibObserverToken = [[NSNotificationCenter defaultCenter] addObserverForName:PSTCollectionViewLayoutAwokeFromNib object:nil queue:nil usingBlock:^(NSNotification *note) {
- self.extVars.nibLayout = note.object;
- }];
- self.extVars.nibObserverToken = nibObserverToken;
+ self.extVars.nibLayout = [inCoder decodeObjectForKey:@"UICollectionLayout"];
NSDictionary *cellExternalObjects = [inCoder decodeObjectForKey:@"UICollectionViewCellPrototypeNibExternalObjects"];
NSDictionary *cellNibs = [inCoder decodeObjectForKey:@"UICollectionViewCellNibDict"];
@@ -206,13 +201,6 @@ - (id)initWithCoder:(NSCoder *)inCoder {
- (void)awakeFromNib {
[super awakeFromNib];
- // check if NIB deserialization found a layout.
- id nibObserverToken = self.extVars.nibObserverToken;
- if (nibObserverToken) {
- [[NSNotificationCenter defaultCenter] removeObserver:nibObserverToken];
- self.extVars.nibObserverToken = nil;
- }
-
PSTCollectionViewLayout *nibLayout = self.extVars.nibLayout;
if (nibLayout) {
self.collectionViewLayout = nibLayout;
@@ -224,11 +212,6 @@ - (NSString *)description {
return [NSString stringWithFormat:@"%@ collection view layout: %@", [super description], self.collectionViewLayout];
}
-- (void)dealloc {
- id nibObserverToken = self.extVars.nibObserverToken;
- if (nibObserverToken) [[NSNotificationCenter defaultCenter] removeObserver:nibObserverToken];
-}
-
///////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - UIView
@@ -1284,7 +1267,7 @@ - (void)setCollectionViewLayout:(PSTCollectionViewLayout *)layout {
- (void)setDelegate:(id<PSTCollectionViewDelegate>)delegate {
self.extVars.collectionViewDelegate = delegate;
-
+
// Managing the Selected Cells
_collectionViewFlags.delegateShouldSelectItemAtIndexPath = [self.delegate respondsToSelector:@selector(collectionView:shouldSelectItemAtIndexPath:)];
_collectionViewFlags.delegateDidSelectItemAtIndexPath = [self.delegate respondsToSelector:@selector(collectionView:didSelectItemAtIndexPath:)];
View
3 PSTCollectionView/PSTCollectionViewLayout.h
@@ -50,9 +50,6 @@ typedef NS_ENUM(NSUInteger, PSTCollectionViewItemType) {
- (BOOL)isCell;
@end
-// used internally for deserialization until I figure out the proper way.
-extern NSString *const PSTCollectionViewLayoutAwokeFromNib;
-
@interface PSTCollectionViewLayout : NSObject <NSCoding>
// Methods in this class are meant to be overridden and will be called by its collection view to gather layout information.
View
5 PSTCollectionView/PSTCollectionViewLayout.m
@@ -212,10 +212,7 @@ @interface PSTCollectionViewLayout() {
@property (nonatomic,copy,readonly) NSDictionary *decorationViewExternalObjectsTables;
@end
-NSString *const PSTCollectionViewLayoutAwokeFromNib = @"PSTCollectionViewLayoutAwokeFromNib";
-
@implementation PSTCollectionViewLayout
-
///////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - NSObject
@@ -228,8 +225,6 @@ - (id)init {
_finalAnimationLayoutAttributesDict = [NSMutableDictionary new];
_insertedSectionsSet = [NSMutableIndexSet new];
_deletedSectionsSet = [NSMutableIndexSet new];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:PSTCollectionViewLayoutAwokeFromNib object:self];
}
return self;
}

0 comments on commit 11ab111

Please sign in to comment.