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
27 changes: 27 additions & 0 deletions BroBoard/BroBoard.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = D9DDFAEB16AB2C6000350F2B /* [email protected] */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -42,6 +46,13 @@
28C66826156F3E84008E82CF /* PSCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSCollectionViewCell.m; path = ../PSCollectionViewCell.m; sourceTree = "<group>"; };
28C6682A156F4073008E82CF /* PSBroView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSBroView.h; sourceTree = "<group>"; };
28C6682B156F4073008E82CF /* PSBroView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSBroView.m; sourceTree = "<group>"; };
D9DDFAE216AB2C5500350F2B /* PSCollectionViewItemLayoutAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSCollectionViewItemLayoutAttributes.h; path = ../PSCollectionViewItemLayoutAttributes.h; sourceTree = "<group>"; };
D9DDFAE316AB2C5500350F2B /* PSCollectionViewItemLayoutAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSCollectionViewItemLayoutAttributes.m; path = ../PSCollectionViewItemLayoutAttributes.m; sourceTree = "<group>"; };
D9DDFAE416AB2C5500350F2B /* PSCollectionViewLayoutAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSCollectionViewLayoutAttributes.h; path = ../PSCollectionViewLayoutAttributes.h; sourceTree = "<group>"; };
D9DDFAE516AB2C5500350F2B /* PSCollectionViewLayoutAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSCollectionViewLayoutAttributes.m; path = ../PSCollectionViewLayoutAttributes.m; sourceTree = "<group>"; };
D9DDFAE616AB2C5500350F2B /* PSCollectionViewSectionViewLayoutAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSCollectionViewSectionViewLayoutAttributes.h; path = ../PSCollectionViewSectionViewLayoutAttributes.h; sourceTree = "<group>"; };
D9DDFAE716AB2C5500350F2B /* PSCollectionViewSectionViewLayoutAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSCollectionViewSectionViewLayoutAttributes.m; path = ../PSCollectionViewSectionViewLayoutAttributes.m; sourceTree = "<group>"; };
D9DDFAEB16AB2C6000350F2B /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -61,6 +72,7 @@
28C667F4156F3E60008E82CF = {
isa = PBXGroup;
children = (
D9DDFAEB16AB2C6000350F2B /* [email protected] */,
28C66829156F3E88008E82CF /* PSCollectionView */,
28C66809156F3E60008E82CF /* BroBoard */,
28C66802156F3E60008E82CF /* Frameworks */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -178,6 +196,7 @@
28C6680E156F3E60008E82CF /* InfoPlist.strings in Resources */,
28C6681A156F3E60008E82CF /* PSViewController_iPhone.xib in Resources */,
28C6681D156F3E60008E82CF /* PSViewController_iPad.xib in Resources */,
D9DDFAEC16AB2C6000350F2B /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -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;
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -313,6 +339,7 @@
28C66822156F3E60008E82CF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
13 changes: 3 additions & 10 deletions BroBoard/BroBoard/PSAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 2 additions & 3 deletions BroBoard/BroBoard/PSBroView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -53,7 +53,6 @@ - (void)prepareForReuse {
- (void)dealloc {
self.imageView = nil;
self.captionLabel = nil;
[super dealloc];
}

- (void)layoutSubviews {
Expand Down
24 changes: 14 additions & 10 deletions BroBoard/BroBoard/PSViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ - (void)dealloc {
self.collectionView.collectionViewDataSource = nil;

self.collectionView = nil;
self.items = nil;

[super dealloc];
self.items = nil;
}

- (void)viewDidLoad {
Expand Down Expand Up @@ -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];
Expand All @@ -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];
}
Expand All @@ -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];
}
Expand Down
Binary file added BroBoard/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions PSCollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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]];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indexPathForRow:inSection doesn't quite make sense due to there being multiple items horizontally (in one "row"). We use indexPathForItem:inSection: to conform similarly to how UICollectionView does. The PSViewController in the BroBoard example seems to still use the row property, when really it should be using the item property instead. See: http://developer.apple.com/library/ios/#documentation/uikit/reference/NSIndexPath_UIKitAdditions/Reference/Reference.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. Unfortunately indexPathForItem doesn't run on iOS 5.x devices. :(

I ended up switching to
https://github.com/steipete/PSTCollectionViewbecause it is a clone of
the UICollectionView
API backported to iOS 4.3+.

On Mon, Jan 21, 2013 at 6:55 AM, Carson Brown [email protected]:

In PSCollectionView.m:

@@ -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]];
    

indexPathForRow:inSection doesn't quite make sense due to there being
multiple items horizontally (in one "row"). We use
indexPathForItem:inSection: to conform similarly to how UICollectionView
does. The PSViewController in the BroBoard example seems to still use the
row property, when really it should be using the item property instead.
See:
http://developer.apple.com/library/ios/#documentation/uikit/reference/NSIndexPath_UIKitAdditions/Reference/Reference.html


Reply to this email directly or view it on GitHubhttps://github.com//pull/14/files#r2713193.

*stop = YES;
}
}];
}];

PSCollectionViewCell *cell = selectedCell.visibleCell;
if (cell) {
if (cell && [self.collectionViewDelegate respondsToSelector:@selector(collectionView:didSelectView:atIndexPath:)]) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent catch!

[self.collectionViewDelegate collectionView:self didSelectView:cell atIndexPath:selectedIndexPath];
}
}
Expand Down