Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,9 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "RACollectionViewReorderableTripletLayout-Demo/RACollectionViewReorderableTripletLayout-Demo-Prefix.pch";
INFOPLIST_FILE = "RACollectionViewReorderableTripletLayout-Demo/RACollectionViewReorderableTripletLayout-Demo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand All @@ -501,8 +502,9 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "RACollectionViewReorderableTripletLayout-Demo/RACollectionViewReorderableTripletLayout-Demo-Prefix.pch";
INFOPLIST_FILE = "RACollectionViewReorderableTripletLayout-Demo/RACollectionViewReorderableTripletLayout-Demo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,19 @@ - (void)setupPhotosArray
_photosArray = nil;
_photosArray = [NSMutableArray array];
for (NSInteger i = 1; i <= 20; i++) {
NSString *photoName = [NSString stringWithFormat:@"%ld.jpg",i];
NSString *photoName = [NSString stringWithFormat:@"%ld.jpg", i];
UIImage *photo = [UIImage imageNamed:photoName];
[_photosArray addObject:photo];
}
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 2;
return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
if (section == 0) {
return 1;
}
return _photosArray.count;
}

Expand All @@ -74,9 +71,6 @@ - (UIEdgeInsets)insetsForCollectionView:(UICollectionView *)collectionView

- (CGSize)collectionView:(UICollectionView *)collectionView sizeForLargeItemsInSection:(NSInteger)section
{
if (section == 0) {
return CGSizeMake(320, 200);
}
return RACollectionViewTripletLayoutStyleSquare; //same as default !
}

Expand Down Expand Up @@ -109,42 +103,27 @@ - (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSInd

- (BOOL)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath canMoveToIndexPath:(NSIndexPath *)toIndexPath
{
if (toIndexPath.section == 0) {
return NO;
}
return YES;
}

- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return NO;
}
return YES;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
static NSString *cellID = @"headerCell";
UICollectionViewCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
return cell;
}else {
static NSString *cellID = @"cellID";
RACollectionViewCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
[cell.imageView removeFromSuperview];
cell.imageView.frame = cell.bounds;
cell.imageView.image = _photosArray[indexPath.item];
[cell.contentView addSubview:cell.imageView];
return cell;
}
static NSString *cellID = @"cellID";
RACollectionViewCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
[cell.imageView removeFromSuperview];
cell.imageView.frame = cell.bounds;
cell.imageView.image = _photosArray[indexPath.item];
[cell.contentView addSubview:cell.imageView];
return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return;
}
if (_photosArray.count == 1) {
return;
}
Expand Down