Skip to content

Instantly share code, notes, and snippets.

@kubbing
Created December 2, 2015 15:55
Show Gist options
  • Save kubbing/da2143049309f54b6b28 to your computer and use it in GitHub Desktop.
Save kubbing/da2143049309f54b6b28 to your computer and use it in GitHub Desktop.
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
viewControllerForLocation:(CGPoint)location
{
// query the collectionView for index corresponting to the touch location
NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:location];
// just in case
if (!indexPath) { return nil; }
// get the data object corresponding to the pressed cell
HNMemberLite *lite = self.memberService.members[indexPath.row];
// filter out non member objects (aka ads)
if (![lite isKindOfClass:[HNMemberLite class]]) { return nil; }
// set the source rectangle for proper animation
CGRect rect = [self.collectionView layoutAttributesForItemAtIndexPath:indexPath].frame;
[previewingContext setSourceRect:rect];
// instantiate the peek controller and return it
UIViewController *controller = [[HNTMemberPeekViewController alloc] initWithMember:lite];
return controller;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment