0

在我的项目中,我有一个包含水平滚动 UICollectionViews 的 UITableView。所以表格视图中的每个单元格都是一个新的集合视图。我需要在每个单元格的左侧有一个交互式视图。该视图将沿左侧折叠,但如果您点击该视图,它将动画打开一点。如果集合视图一直滚动到左侧,即开头,它将打开。一旦用户开始滚动集合视图,它将自动关闭。

这是一个视觉示例:

表视图单元格..

The view is collapsed in this image.
____________________________
|V |                       |
|i |    CollectionView     |
|e |    Scrolls </>        |
|w_|_______________________|    


The view is open in this image. The ways it opens are described above.
____________________________
|V      |                  |
|i      |  CollectionView  |
|e      |  Scrolls </>     |
|w______|__________________|   

我怎样才能在我的单元格的左侧拥有这个交互式控制器,其中已经有集合视图?

此外,如果有任何 3rd 方控件可以用于这样的事情,那也很棒!

4

1 回答 1

1

那将是一个UIView- 不是UIViewController- 放在UICollectionView.

UICollectionView委托方法中,只要第一个集合视图单元格可见cellForItemAtIndexPath,您就可以展开和缩回:cellLeftSideView

if ([[cell_CollectionView indexPathsForVisibleItems] containsObject:[NSIndexPath indexPathForItem:0 inSection:0]]) {

    // First item IS showing in collection view
    // Make sure left side view is expanded

    [UIView animateWithDuration:0.5 animations:^{
        CGRect aFrame = cell_LeftSideView.frame;
        aFrame.size.width = kCellLeftSideView_Width_Max;    // <= #define maximum width value
        cell_LeftSideView.frame = aFrame;
    }];
}
else
{
    // First item is NOT showing in collection view
    // Make sure left side view is shrunk

    [UIView animateWithDuration:0.5 animations:^{
        CGRect aFrame = cell_LeftSideView.frame;
        aFrame.size.width = kCellLeftSideView_Width_Min;    // <= #define minimum width value
        cell_LeftSideView.frame = aFrame;
    }];
}
于 2013-10-07T03:28:32.590 回答