From 03fcad3f29d56299ff740135d23a4333b042990e Mon Sep 17 00:00:00 2001 From: GabrielAlva Date: Tue, 7 Jul 2015 15:18:41 -0600 Subject: [PATCH] Updated the demo project with size classes, now it works on iPad and iPhone. --- .../project.pbxproj | 6 ++- .../RAViewController.m | 39 +++++-------------- 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/Example/RACollectionViewReorderableTripletLayout-Demo.xcodeproj/project.pbxproj b/Example/RACollectionViewReorderableTripletLayout-Demo.xcodeproj/project.pbxproj index a87180e..eb63bd9 100644 --- a/Example/RACollectionViewReorderableTripletLayout-Demo.xcodeproj/project.pbxproj +++ b/Example/RACollectionViewReorderableTripletLayout-Demo.xcodeproj/project.pbxproj @@ -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; @@ -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; diff --git a/Example/RACollectionViewReorderableTripletLayout-Demo/RAViewController.m b/Example/RACollectionViewReorderableTripletLayout-Demo/RAViewController.m index b366244..60acbaa 100644 --- a/Example/RACollectionViewReorderableTripletLayout-Demo/RAViewController.m +++ b/Example/RACollectionViewReorderableTripletLayout-Demo/RAViewController.m @@ -33,7 +33,7 @@ - (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]; } @@ -41,14 +41,11 @@ - (void)setupPhotosArray - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { - return 2; + return 1; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { - if (section == 0) { - return 1; - } return _photosArray.count; } @@ -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 ! } @@ -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; }