Skip to content

Commit

Permalink
[collections] Detail and navigation actions are treated like taps.
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey committed Apr 18, 2013
1 parent 0a4514e commit 93666fc
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/collections/src/NICollectionViewActions.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtI
NIObjectActions* action = [self actionForObjectOrClassOfObject:object];

// If the cell is tappable, reflect that in the selection style.
if (nil != action.tapAction || nil != action.tapSelector) {
if (nil != action.tapAction || nil != action.tapSelector
|| nil != action.detailAction || nil != action.detailSelector
|| nil != action.navigationAction || nil != action.navigationSelector) {
shouldHighlight = YES;
}
}
Expand Down Expand Up @@ -100,6 +102,29 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
free(buffer);
}
}

if (action.detailAction) {
// Tap actions can deselect the cell if they return YES.
action.detailAction(object, self.target, indexPath);
}
if (action.detailSelector && [self.target respondsToSelector:action.detailSelector]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.target performSelector:action.detailSelector withObject:object withObject:indexPath];
#pragma clang diagnostic pop
}

if (action.navigateAction) {
// Tap actions can deselect the cell if they return YES.
action.navigateAction(object, self.target, indexPath);
}
if (action.navigateSelector && [self.target respondsToSelector:action.navigateSelector]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.target performSelector:action.navigateSelector withObject:object withObject:indexPath];
#pragma clang diagnostic pop
}

if (shouldDeselect) {
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
}
Expand Down

0 comments on commit 93666fc

Please sign in to comment.