Skip to content

Commit

Permalink
disables prefetchEnabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
svenbacia committed Dec 12, 2016
1 parent fc56c02 commit 39dbeea
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Source/IGListCollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,25 @@ - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionVi
self.backgroundColor = [UIColor whiteColor];
}

self.alwaysBounceVertical = YES;
[self updateIGListCollectionViewDefaultValues];
}
return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
[self updateIGListCollectionViewDefaultValues];
}
return self;
}

- (void)updateIGListCollectionViewDefaultValues {
if ([self respondsToSelector:@selector(setPrefetchingEnabled:)]) {
self.prefetchingEnabled = NO;
}
self.alwaysBounceVertical = YES;
}

- (void)layoutSubviews {
/**
UICollectionView will sometimes lay its cells out with an animation. This is especially noticeable on older devices
Expand Down
18 changes: 18 additions & 0 deletions Tests/IGListCollectionViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ -(void)test_thatIGListCollectionViewHasCorrectDefaults {
IGListCollectionView *collectionView = [[IGListCollectionView alloc] initWithFrame: kIGListCollectionViewTestFrame collectionViewLayout:[UICollectionViewFlowLayout new]];

XCTAssertTrue(collectionView.alwaysBounceVertical);

if ([collectionView respondsToSelector:@selector(isPrefetchingEnabled)]) {
XCTAssertFalse(collectionView.isPrefetchingEnabled);
}
}

-(void)test_thatStoryboardIGListCollectionViewHasCorrectDefaults {
UIWindow *window = [[UIWindow alloc] initWithFrame:kIGListCollectionViewTestFrame];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"IGTestStoryboard" bundle:[NSBundle bundleForClass:self.class]];
IGTestStoryboardViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"testVC"];
[window addSubview:viewController.view];
[viewController performSelectorOnMainThread:@selector(loadView) withObject:nil waitUntilDone:YES];

XCTAssertTrue(viewController.collectionView.alwaysBounceVertical);

if ([UICollectionView instancesRespondToSelector:@selector(isPrefetchingEnabled)]) {
XCTAssertFalse(viewController.collectionView.isPrefetchingEnabled);
}
}

-(void)test_whenUsingUIAppearance_thatStoryboardIGListCollectionViewUsesAppearanceBackgroundColor {
Expand Down

0 comments on commit 39dbeea

Please sign in to comment.