diff --git a/BroBoard/BroBoard.xcodeproj/project.pbxproj b/BroBoard/BroBoard.xcodeproj/project.pbxproj index b6a560f..20d13f0 100644 --- a/BroBoard/BroBoard.xcodeproj/project.pbxproj +++ b/BroBoard/BroBoard.xcodeproj/project.pbxproj @@ -19,6 +19,10 @@ 28C66827156F3E84008E82CF /* PSCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 28C66824156F3E84008E82CF /* PSCollectionView.m */; }; 28C66828156F3E84008E82CF /* PSCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 28C66826156F3E84008E82CF /* PSCollectionViewCell.m */; }; 28C6682C156F4073008E82CF /* PSBroView.m in Sources */ = {isa = PBXBuildFile; fileRef = 28C6682B156F4073008E82CF /* PSBroView.m */; }; + D9DDFAE816AB2C5500350F2B /* PSCollectionViewItemLayoutAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = D9DDFAE316AB2C5500350F2B /* PSCollectionViewItemLayoutAttributes.m */; }; + D9DDFAE916AB2C5500350F2B /* PSCollectionViewLayoutAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = D9DDFAE516AB2C5500350F2B /* PSCollectionViewLayoutAttributes.m */; }; + D9DDFAEA16AB2C5500350F2B /* PSCollectionViewSectionViewLayoutAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = D9DDFAE716AB2C5500350F2B /* PSCollectionViewSectionViewLayoutAttributes.m */; }; + D9DDFAEC16AB2C6000350F2B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D9DDFAEB16AB2C6000350F2B /* Default-568h@2x.png */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -42,6 +46,13 @@ 28C66826156F3E84008E82CF /* PSCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSCollectionViewCell.m; path = ../PSCollectionViewCell.m; sourceTree = ""; }; 28C6682A156F4073008E82CF /* PSBroView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSBroView.h; sourceTree = ""; }; 28C6682B156F4073008E82CF /* PSBroView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSBroView.m; sourceTree = ""; }; + D9DDFAE216AB2C5500350F2B /* PSCollectionViewItemLayoutAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSCollectionViewItemLayoutAttributes.h; path = ../PSCollectionViewItemLayoutAttributes.h; sourceTree = ""; }; + D9DDFAE316AB2C5500350F2B /* PSCollectionViewItemLayoutAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSCollectionViewItemLayoutAttributes.m; path = ../PSCollectionViewItemLayoutAttributes.m; sourceTree = ""; }; + D9DDFAE416AB2C5500350F2B /* PSCollectionViewLayoutAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSCollectionViewLayoutAttributes.h; path = ../PSCollectionViewLayoutAttributes.h; sourceTree = ""; }; + D9DDFAE516AB2C5500350F2B /* PSCollectionViewLayoutAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSCollectionViewLayoutAttributes.m; path = ../PSCollectionViewLayoutAttributes.m; sourceTree = ""; }; + D9DDFAE616AB2C5500350F2B /* PSCollectionViewSectionViewLayoutAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSCollectionViewSectionViewLayoutAttributes.h; path = ../PSCollectionViewSectionViewLayoutAttributes.h; sourceTree = ""; }; + D9DDFAE716AB2C5500350F2B /* PSCollectionViewSectionViewLayoutAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSCollectionViewSectionViewLayoutAttributes.m; path = ../PSCollectionViewSectionViewLayoutAttributes.m; sourceTree = ""; }; + D9DDFAEB16AB2C6000350F2B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -61,6 +72,7 @@ 28C667F4156F3E60008E82CF = { isa = PBXGroup; children = ( + D9DDFAEB16AB2C6000350F2B /* Default-568h@2x.png */, 28C66829156F3E88008E82CF /* PSCollectionView */, 28C66809156F3E60008E82CF /* BroBoard */, 28C66802156F3E60008E82CF /* Frameworks */, @@ -116,6 +128,12 @@ 28C66829156F3E88008E82CF /* PSCollectionView */ = { isa = PBXGroup; children = ( + D9DDFAE216AB2C5500350F2B /* PSCollectionViewItemLayoutAttributes.h */, + D9DDFAE316AB2C5500350F2B /* PSCollectionViewItemLayoutAttributes.m */, + D9DDFAE416AB2C5500350F2B /* PSCollectionViewLayoutAttributes.h */, + D9DDFAE516AB2C5500350F2B /* PSCollectionViewLayoutAttributes.m */, + D9DDFAE616AB2C5500350F2B /* PSCollectionViewSectionViewLayoutAttributes.h */, + D9DDFAE716AB2C5500350F2B /* PSCollectionViewSectionViewLayoutAttributes.m */, 28C66823156F3E84008E82CF /* PSCollectionView.h */, 28C66824156F3E84008E82CF /* PSCollectionView.m */, 28C66825156F3E84008E82CF /* PSCollectionViewCell.h */, @@ -178,6 +196,7 @@ 28C6680E156F3E60008E82CF /* InfoPlist.strings in Resources */, 28C6681A156F3E60008E82CF /* PSViewController_iPhone.xib in Resources */, 28C6681D156F3E60008E82CF /* PSViewController_iPad.xib in Resources */, + D9DDFAEC16AB2C6000350F2B /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -194,6 +213,9 @@ 28C66827156F3E84008E82CF /* PSCollectionView.m in Sources */, 28C66828156F3E84008E82CF /* PSCollectionViewCell.m in Sources */, 28C6682C156F4073008E82CF /* PSBroView.m in Sources */, + D9DDFAE816AB2C5500350F2B /* PSCollectionViewItemLayoutAttributes.m in Sources */, + D9DDFAE916AB2C5500350F2B /* PSCollectionViewLayoutAttributes.m in Sources */, + D9DDFAEA16AB2C5500350F2B /* PSCollectionViewSectionViewLayoutAttributes.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -232,6 +254,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -257,6 +280,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -278,6 +302,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "BroBoard/BroBoard-Prefix.pch"; INFOPLIST_FILE = "BroBoard/BroBoard-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -289,6 +314,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "BroBoard/BroBoard-Prefix.pch"; INFOPLIST_FILE = "BroBoard/BroBoard-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -313,6 +339,7 @@ 28C66822156F3E60008E82CF /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/BroBoard/BroBoard/PSAppDelegate.m b/BroBoard/BroBoard/PSAppDelegate.m index faf8bbc..54d83aa 100644 --- a/BroBoard/BroBoard/PSAppDelegate.m +++ b/BroBoard/BroBoard/PSAppDelegate.m @@ -15,21 +15,14 @@ @implementation PSAppDelegate @synthesize window = _window; @synthesize viewController = _viewController; -- (void)dealloc -{ - [_window release]; - [_viewController release]; - [super dealloc]; -} - - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { - self.viewController = [[[PSViewController alloc] initWithNibName:@"PSViewController_iPhone" bundle:nil] autorelease]; + self.viewController = [[PSViewController alloc] initWithNibName:@"PSViewController_iPhone" bundle:nil]; } else { - self.viewController = [[[PSViewController alloc] initWithNibName:@"PSViewController_iPad" bundle:nil] autorelease]; + self.viewController = [[PSViewController alloc] initWithNibName:@"PSViewController_iPad" bundle:nil]; } self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; diff --git a/BroBoard/BroBoard/PSBroView.m b/BroBoard/BroBoard/PSBroView.m index 71ae288..8c78a0e 100644 --- a/BroBoard/BroBoard/PSBroView.m +++ b/BroBoard/BroBoard/PSBroView.m @@ -32,11 +32,11 @@ - (id)initWithFrame:(CGRect)frame { if (self) { self.backgroundColor = [UIColor whiteColor]; - self.imageView = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease]; + self.imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; self.imageView.clipsToBounds = YES; [self addSubview:self.imageView]; - self.captionLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; + self.captionLabel = [[UILabel alloc] initWithFrame:CGRectZero]; self.captionLabel.font = [UIFont boldSystemFontOfSize:14.0]; self.captionLabel.numberOfLines = 0; [self addSubview:self.captionLabel]; @@ -53,7 +53,6 @@ - (void)prepareForReuse { - (void)dealloc { self.imageView = nil; self.captionLabel = nil; - [super dealloc]; } - (void)layoutSubviews { diff --git a/BroBoard/BroBoard/PSViewController.m b/BroBoard/BroBoard/PSViewController.m index be0f65e..e11fef8 100644 --- a/BroBoard/BroBoard/PSViewController.m +++ b/BroBoard/BroBoard/PSViewController.m @@ -63,9 +63,7 @@ - (void)dealloc { self.collectionView.collectionViewDataSource = nil; self.collectionView = nil; - self.items = nil; - - [super dealloc]; + self.items = nil; } - (void)viewDidLoad { @@ -110,7 +108,7 @@ - (void)loadDataSource { if (!error && responseCode == 200) { id res = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; if (res && [res isKindOfClass:[NSDictionary class]]) { - self.items = [res objectForKey:@"gallery"]; + self.items = [res objectForKey:@"data"]; [self dataSourceDidLoad]; } else { [self dataSourceDidError]; @@ -130,14 +128,20 @@ - (void)dataSourceDidError { } #pragma mark - PSCollectionViewDelegate and DataSource -- (NSInteger)numberOfViewsInCollectionView:(PSCollectionView *)collectionView { + +- (NSUInteger) numberOfSectionsInCollectionView:(PSCollectionView *)collectionView { + return 1; +} + +- (NSUInteger) collectionView:(PSCollectionView *)collectionView numberOfViewsInSection:(NSUInteger)section { return [self.items count]; } -- (PSCollectionViewCell *)collectionView:(PSCollectionView *)collectionView viewAtIndex:(NSInteger)index { - NSDictionary *item = [self.items objectAtIndex:index]; +- (PSCollectionViewCell *)collectionView:(PSCollectionView *)collectionView viewAtIndexPath:(NSIndexPath *)indexPath { + static NSString *viewIdentifier = @"ViewIdentifier"; + NSDictionary *item = [self.items objectAtIndex:indexPath.row]; - PSBroView *v = (PSBroView *)[self.collectionView dequeueReusableView]; + PSBroView *v = (PSBroView *)[self.collectionView dequeueReusableViewWithIdentifier:viewIdentifier]; if (!v) { v = [[PSBroView alloc] initWithFrame:CGRectZero]; } @@ -147,8 +151,8 @@ - (PSCollectionViewCell *)collectionView:(PSCollectionView *)collectionView view return v; } -- (CGFloat)heightForViewAtIndex:(NSInteger)index { - NSDictionary *item = [self.items objectAtIndex:index]; +- (CGFloat)collectionView:(PSCollectionView *)collectionView heightForViewAtIndexPath:(NSIndexPath *)indexPath { + NSDictionary *item = [self.items objectAtIndex:indexPath.row]; return [PSBroView heightForViewWithObject:item inColumnWidth:self.collectionView.colWidth]; } diff --git a/BroBoard/Default-568h@2x.png b/BroBoard/Default-568h@2x.png new file mode 100644 index 0000000..0891b7a Binary files /dev/null and b/BroBoard/Default-568h@2x.png differ diff --git a/PSCollectionView.m b/PSCollectionView.m index 2fb41ef..0e33ae1 100644 --- a/PSCollectionView.m +++ b/PSCollectionView.m @@ -453,8 +453,8 @@ - (void)performLayout NSMutableArray *sectionItems = _sectionItems[sectionNumber]; [sectionItems enumerateObjectsUsingBlock:^(PSCollectionViewItemLayoutAttributes *itemAttributes, NSUInteger idx, BOOL *stop) { if (itemAttributes.valid == NO) { - NSIndexPath *indexPath = [NSIndexPath indexPathForItem:idx inSection:section]; - + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:idx inSection:section]; + //ensure we have the height for this item CGFloat height = itemAttributes.frame.size.height; if (height == 0.0f) { @@ -500,7 +500,7 @@ - (void)performLayout itemAttributes.visibleCell = nil; } else if (visibleCell && itemAttributes.visibleCell == nil) { //Cell is now visible, add it in - NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:[sectionNumber integerValue]]; + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:[sectionNumber integerValue]]; PSCollectionViewCell *newCell = [self.collectionViewDataSource collectionView:self viewAtIndexPath:indexPath]; itemAttributes.visibleCell = newCell; [self addSubview:newCell]; @@ -826,14 +826,14 @@ - (void)didSelectView:(UITapGestureRecognizer *)gestureRecognizer [sectionItems enumerateObjectsUsingBlock:^(PSCollectionViewItemLayoutAttributes *candidate, NSUInteger idx, BOOL *stop) { if (candidate.valid && CGRectContainsPoint(candidate.frame, tapPoint)) { selectedCell = candidate; - selectedIndexPath = [NSIndexPath indexPathForItem:idx inSection:[sectionNumber integerValue]]; + selectedIndexPath = [NSIndexPath indexPathForRow:idx inSection:[sectionNumber integerValue]]; *stop = YES; } }]; }]; PSCollectionViewCell *cell = selectedCell.visibleCell; - if (cell) { + if (cell && [self.collectionViewDelegate respondsToSelector:@selector(collectionView:didSelectView:atIndexPath:)]) { [self.collectionViewDelegate collectionView:self didSelectView:cell atIndexPath:selectedIndexPath]; } }