Tag: uicollectionview

UICollectionView moveItemAtIndexPath:toIndexPath:发出不在屏幕上的移动项目

我试图在iOS 6的UICollectionView中重新设置项目的animation。 我写了这个代码: NSMutableDictionary *from = [NSMutableDictionary dictionaryWithCapacity:self.count]; for (int ii = 0; ii < self.count; ii++) { MyItem item = [self getItemAtIndex:(NSInteger)ii]; [from setObject:[NSNumber numberWithInt:ii] forKey:[NSNumber numberWithInt:item.id]]; } [self sort]; [self.collectionView performBatchUpdates:^{ for (int ii = 0; ii < self.count; ii++) { MyItem item = [self getItemAtIndex:(NSInteger)ii]; NSNumber *prevPos = (NSNumber *)[from objectForKey:[NSNumber numberWithInt:item.id]]; […]

UICollectionViewLayout layoutAttributesForElementsInRect和layoutAttributesForItemAtIndexPath

我正在实现一个自定义stream布局。 它有2个主要的方法来重写确定单元格的位置: layoutAttributesForElementsInRect和layoutAttributesForItemAtIndexPath 。 在我的代码中, layoutAttributesForElementsInRect被调用,但是layoutAttributesForItemAtIndexPath不是。 什么决定哪些被调用? layoutAttributesForItemAtIndexPath在哪里被调用?

在单元格上设置圆angular半径会导致UICollectionView的性能下降

我有一个只有几个单元格(约20)的UICollectionView 。 这个集合的性能很好。 但是,当我尝试围绕由这个视图呈现的UICollectionViewCells的angular落时,我的performance受到重创。 在我的单元格的init方法中,这是我添加的唯一原因: [self.layer setCornerRadius:15]; 由于这是在init方法中,我正在重用这些单元格,所以我不明白为什么这会引起我的问​​题。 我已经尝试使用以下的多个组合来调整销售的光栅化和不透明度,但仍然没有效果: [self.layer setMasksToBounds:YES]; [self.layer setCornerRadius:15]; [self.layer setRasterizationScale:[[UIScreen mainScreen] scale]]; self.layer.shouldRasterize = YES; self.layer.opaque = YES; 是他们的一些设置或技巧来提高具有圆angular单元格的UICollectionView的性能?

指定UICollectionView的行号和列号

我想要显示一个UICollectionView,其中每行包含2行和100个单元格。 // 1 – (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section { return 100; } // 2 – (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView { return 2; } // 3 – (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath { MyCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath]; cell.lbl.text = @"Data"; return cell; } 我得到这个: 我怎样才能为UICollectionView指定行号? 我想创build一个2×100表。

在集合视图中显示两个不同的单元格 – Swift 2.0 iOS

我正在一个“交易”应用程序,我想有一个静态数量的单元格。 加载时,用户将看到5个单元格,每个单元格显示一个标签,上面写着“添加”。 当添加“玩家”时,该单元显示玩家信息,其他4个单元仍显示“添加”标签。 另外还有2个单元格有玩家信息,3个有“添加” 我有一个这个地狱。 任何人都可以指出我的方向正确吗? 我有自定义标签设置,我想我的逻辑可能只是closures如何正确执行此操作。

如何在UICollectionViewCell上设置UILabel?

我用自定义和标准的UITableView单元做了几十次。 我的所有网点都已连接。 UILabel是IB中我的UICollectionViewCell的子视图。 我的UICollectionViewCell对象在身份检查器中inheritance适当的类。 如何在UICollectionViewCell上设置UILabel ? MyCell.m -(void)setCellName:(NSString *)cellName { self.cellLabel.text = cellName; } ViewController.m – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { ADMCell *cell = (ADMCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"ADMCell" forIndexPath:indexPath]; [cell setCellName:[NSString stringWithFormat:@"%d",[indexPath row]]]; return cell; } cell.debugDescription的输出: 2013-05-15 22:05:40.191 ProductName[857:c07] cell.debugDescription: <ADMCell: 0xb35c890; baseClass = UICollectionViewCell; frame = (245 266; 70 80); layer = <CALayer: […]

iOS中有多列到UITableView

我正在从MySQL数据加载到数组,我想在UITableCiew填充它们。 我怎么能添加多个列(在我的情况下4)到UITableView ? 我能够加载行数据,但我不明白我怎么能把它分成列。 UICollectionView是一个选项吗? 如果是这样,我该怎么办呢?

如何在iOS的CollectionView的页脚中添加加载指标

当数据加载到下一页时,如何在集合视图的页脚中添加加载指示器..? 我想要加载指标在收集视图的页脚与上面的图像相同。 但我无法做到这一点。 那么有没有可能? 否则,我必须使用tableview创build这种types的列表视图。 因为我们可以轻松地将这些东西pipe理成tableview。 任何帮助,将不胜感激。

UICollectionView在iOS中删除单元格的animation时间

我正在使用集合视图为第一次我需要删除点击集合视图单元格,这是适合我的工作。但我挣扎着UIcollectionview的animation时间。它总是相同的。我怎样才能增加或减less删除单元格的animation时间。我也把这个代码在uianimation块,但它不工作。 这是我的代码删除,任何意见将不胜感激。 [self.collectionView performBatchUpdates:^{ NSArray* itemPaths = [self.collectionView indexPathsForSelectedItems]; // Delete the items from the data source. [self deleteItemsFromDataSourceAtIndexPaths:itemPaths]; // Now delete the items from the collection view. [self.collectionView deleteItemsAtIndexPaths:tempArray } completion:nil];

UICollectoin查看水平卷轴与项目间距

我正在使用我的一些图像的集合视图。 每个图像应该以屏幕大小显示,因此一个单元格具有屏幕宽度。 minimumInterItemSpacing的minimumInterItemSpacing是25.所以现在的问题是,如果我滚动,集合视图不滚动到下一个图像的开始,而是interItemSpacing的开始。 我们来举个例子: Image/Cell width = 320 CollectionView's interItemSpacing = 25 如果我滚动一个页面,那么滚动视图的内容偏移是在320而不是在345,这意味着第二个单元不在屏幕的中心。 如何解决这个问题? 有什么build议么?