Tag: 自我评价

UICollectionView将项目移动到新的部分

我遇到了一个UICollectionViewanimation的严重问题,类似于这里提到的问题: UICollectionView在重新安排部分之间的项目时崩溃 比方说,我有一个UICollectionView与5个不同的部分,每个10个单元格。 我想用animation更新CollectionView,所以单元格将被重新sorting为10个部分。 不会添加新内容的单元格,也不会删除现有的单元格。 因此,我正在执行批量更新: [_resultCollectionView performBatchUpdates:^{ [_resultCollectionView insertSections:insertSections]; [_resultCollectionView deleteSections:deleteSections]; //[_resultCollectionView insertItemsAtIndexPaths:insertIndexPaths]; //[_resultCollectionView deleteItemsAtIndexPaths:deleteIndexPaths]; for (all items which need to be moved…) { [_resultCollectionView moveItemAtIndexPath:sourcePath toIndexPath:destinationPath]; } } completion:^(BOOL finished) { //[_resultCollectionView reloadData]; nil; }]; 如果我执行insertSections,deleteSections,insertItemsAtIndexPath,deleteItemsAtIndexPath和reloadData ,一切都可以正常工作,这意味着我的dataSource和委托在理论上正常工作。 除了它还没有animation… 如果我执行insertSections,deleteSections和moveItemAtIndexPath (这应该工作,因为单元格只重新排列),我得到这个小错误: 不能将一行移动到新插入的部分(5) 如果我执行insertSections,deleteSections和moveItemAtIndexPath但排除任何移动到一个新插入的部分,我显然在节中的项目数量无效。 有没有人有这个问题的解决scheme?

我如何创build像这个图像中的集合视图

我需要第一个两个细胞小的第二个两个大的再两个小的两个大的。 我已经尝试了下面的code.but它不给我适当的output.else任何第三方库,这是很容易实现这个等待这个问题的答案。 – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ if (collectionView == _CollectionSale) { if (small && j != 2){ j++; if(j==2){ small = false; k = 0; } HomeSaleCC *objHomeSaleCC=[collectionView dequeueReusableCellWithReuseIdentifier:@"HomeSaleCC" forIndexPath:indexPath]; return objHomeSaleCC; }else if(!small && k !=2){ k++; if(k==2){ small = true; j = 0; } HomeSaleCC2 *objHomeSaleCC2=[collectionView dequeueReusableCellWithReuseIdentifier:@"HomeSaleCC2" forIndexPath:indexPath]; return objHomeSaleCC2; } […]

UICollectionView:用于分页的外屏自动滚动

我想通过下面的代码滚动我的应用程序中的UICollectionView 。 int pages = ceil(aCollectionView.contentSize.height / aCollectionView.frame.size.height); for (int i = 0; i < pages; i ++) { NSArray *sortedVisibleItems = [[aCollectionView indexPathsForVisibleItems] sortedArrayUsingSelector:@selector(compare:)]; NSIndexPath *lastItem = [sortedVisibleItems lastObject]; // 2.next position NSInteger nextItem = lastItem.item + 1; NSInteger nextSection = lastItem.section; NSIndexPath *nextIndexPath = [NSIndexPath indexPathForItem:nextItem inSection:nextSection]; [self takeImage]; dispatch_async(dispatch_get_main_queue(), ^ { [aCollectionView […]

尝试插入新的项目到UICollectionView,但一遍又一遍地获得相同的单元格

我的UICollectionView设置为3行3个部分。 我试图插入一个批量(数组)9的项目到CollectionView,但下面的代码,我得到了我的批量显示在所有3个部分的前3件事情。 分批:蓝色,红色,绿色,橙色,鱼,沙子,帽子,鞋子,黑色 显示当前结果: blue blue blue red red red green green green 当前代码: … [self.selectedSearches addObject:string]; [self.collectionView insertItemsAtIndexPaths:@[[NSIndexPath indexPathForRow:self.selectedSearches.count-1 inSection:0]]]; … 不知道我在做什么错。

UICollectionView不滚动到位置

我有一个静态的UITableView UICollectionView 。 我正在尝试使collectionView滚动到viewDidLoad的indexPath 。 它不会滚动到启动位置,当我select一个indexPath它滚动到该位置。 我做了一个清洁的项目,产生了这个问题。 我认为最简单的方法就是不要让你尝试重现问题,而只是上传它。 所以这里是: 有问题的项目

UICollectionView – 根据水平滚动更新数组索引path

您好我使用两个收集单元格来显示数据,子集合视图值是基于主集合视图。 我有video列表,当我selectvideo在表即时通讯完整的数组在索引path,以便主集合视图将显示基于选定的数组的索引path。 它显示正常,但是当我滚动水平,我传递可见的单元格indexPath数据来获取子集合查看数据。 但是,当我滚动主集合视图,在indexPath数组不会更新基于主集合视图它始终显示相同的IndexPath从video列表(前视图控制器)。 如何更新基于水平滚动的主集合视图数组。 我想要离开这个场景 – 例如VIdeo列表数组是1,2,3,4 我select3索引,并传递给videolist数组的collections视图,显示选定的索引path行值,当我向右滚动索引path应该增加到4左右它应该减less到2,对于video上select的任何值列表数组。 主集合视图应该基于传递的索引path工作,并根据其索引path行事 我的代码 – – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { if(self.childCollectionView ==collectionView) { return [self.array_ChildElements count]; } else { return [self.array_VideoList count]; } } – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { if (collectionView ==self.collectionView) { VVCollectionCell *cell = (VVCollectionCell *)[self.collectionView dequeueReusableCellWithReuseIdentifier:@"VVCollectionCell" forIndexPath:indexPath]; VVSystems *obj; if (self.iscalledFromVideoLIst) { obj […]

iOS:UICollectionView单元格select不起作用

我有一个UICollectionView作为IB视图层次结构的顶视图。 它利用了一个自定义的布局,沿着视图的左边和右边拆分单元格(从笔尖注册),后面有装饰视图,并在单元格顶部显示整个视图的大小补充视图。 所有这些按预期工作。 什么不起作用的是,select单元格根本就没有被注册。 它们不会触发对collectionView: didSelectItemAtIndexPath:调用正确设置)的调用,也不会在nib工作中突出显示图像的状态。 它performance得更像是一个更高的视angular消耗水龙头,但collectionView是顶视图。 我尝试删除重叠的补充视图和背景装饰视图,也尝试暂时转换为使用stream布局,以防我的自定义布局做了一些棘手的事情 – 仍然没有。 使这更令人沮丧的是我在这个应用程序中的其他视图控制器上使用collectionView(由stream布局治理),他们工作得很好,没有任何特殊的定制。 我没有select,有什么想法?

iOSpipe理嵌套的UICollectionViews问题

我在处理嵌套的集合视图时遇到了一个问题。 层次如下: outerCollectionView 的UIImageView 标签 innerCollectionView 标签 的UIImageView OuterCollectionView的单元格的大小是屏幕的大小(像刷过页面一样)我已经设置了outerCollectionView的委托和数据源为UIViewController和innerCollectionView的委托和数据源为包含单元格,如下所示: 在ViewController.m中 -(FeaturedPageCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { FeaturedPageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FeaturedCell" forIndexPath:indexPath]; cell.nestedCollectionView.dataSource = cell; cell.nestedCollectionView.delegate = cell; [cell.nestedCollectionView setBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:.01]]; cell.venueThumbnail.image = [UIImage imageNamed:[self.venueThumbnails objectAtIndex:indexPath.item]]; cell.venueNameLabel.text = [self.venueNames objectAtIndex:indexPath.item]; cell.venueNameLabel.textColor = [UIColor whiteColor]; cell.venueAddressLabel.text = [self.venueAddresses objectAtIndex:indexPath.item]; cell.venueAddressLabel.textColor = [UIColor whiteColor]; [cell setBackgroundColor:[[UIColor […]

在ViewController中创build多个UICollectionView

标题是我的问题。 我在for loop创build了UICollectionView 。 所以,它创build了一些UICollectionView 我的代码: for (int i = 0; i < getAllCategory.count; i ++) { CGRect frame; frame.origin.x = self.scroll.frame.size.width * i; frame.origin.y = 0; frame.size = self.scroll.frame.size; UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init]; collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(screenWidth*i,5,screenWidth ,self.scroll.frame.size.height-5) collectionViewLayout:layout]; [collectionView setDataSource:self]; [collectionView setDelegate:self]; [collectionView setPagingEnabled:YES]; collectionView.showsHorizontalScrollIndicator = NO; collectionView.showsVerticalScrollIndicator = NO; [collectionView registerClass:[UICollectionViewCell […]

集合视图中的部分数量

我有两个UICollectionViews在一个特定的UIViewController ,我希望在他们两个有不同数量的部分。 我一直在以下列方式尝试 – (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView { if (collectionView == self.firstcollectionView) { return objects.count + 1; } else { return 1; } } 但是由于某种原因,这似乎不起作用。 也尝试过与标签,但还没有能够使它的工作方式。 – (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView { if (collectionView.tag == 1) { return objects.count + 1; } else { return 1; } } 它总是在两个UICollectionViews显示一个单独的部分,当我能够检查有一个对象,这意味着在第一个UICollectionView会有两个部分 更新1:在debugging看来,控制永远不会进入如果总是返回1。 更新2:如果条件是问题的地方。 它从来没有得到满足。 更新3:我能够通过将UICollectionViews声明为类variables而不是属性来获得if-else的工作。 虽然UICollectionViews的部分数仍然是1。 – (NSInteger)numberOfSectionsInCollectionView: […]