1

我有运行 UICollectionView 控制器和我自己的 UICollectionView 子类和单元格等。

1)现在我决定在自己的collectionview控制器后面添加slideView,如http://www.raywenderlich.com/32054/how-to-create-a-slide-out-navigation-like-facebook-and-path中所述。2) 然后我不够高兴,因为它没有给我作为 iOS 上的 Facebook 应用程序的“内部峰值”感觉

3) 然后我在自己的 collectionView 子类中修改了代码并处理了触摸。经过这个网站和一些最初的努力后,我现在可以得到和 FB 一样的感觉

4)但在处理触摸的过程中,我丢失了 UICollectionViewDelegate didSelectItemAtIndePath。他们永远不会因为触摸而被叫到。

5)所以我在我的故事板中的 collectionView 上添加了 tapGesture 并将所有内容连接起来并进行了明确的调用

- (IBAction)selectCellWithSingleTap:(UITapGestureRecognizer *)sender
{
    NSLog(@"SELECT");
    CGPoint tapLocation = [sender locationInView:self.collectionView];
    NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:tapLocation];
    if (indexPath) {
        [self collectionView:self.collectionView didSelectItemAtIndexPath:indexPath];
    }
}

1)现在这是正确的方法吗?2)如果不是更好的设计是什么?3)我也想知道这个方法在 UICollectionView 中有什么 selectItemAtIndexPath:animated:scrollPosition: 我可以用这个吗?

4

0 回答 0