Tag: uicollectionviewcell

无法转换“UICollectionViewCell”types的值

我在Storyboard中使用自定义的CollectionViewCell。 当我启动应用程序时,我收到以下消息: 无法将types为“UICollectionViewCell”的值转换为TestProject.CollectionViewCell。

在设置好数据之后调整UICollectionView单元的大小

我的UICollectionView单元格包含带有多行文本的UILabels 。 我不知道UICollectionViewCells的height ,直到在UILabel上设置文本。 -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath; 是我看到的大小UICollectionViewCells的初始方法,但是这被称为之前的单元格创build的UIStoryboard 。 有没有一种方法来布局集合和大小的单元格后,他们已经被渲染,我知道单元格的实际大小?

UICollectionView的dynamic单元格宽度取决于标签宽度

我有一个UICollectionView,从包含标签的可重用单元格加载单元格。 数组提供了该标签的内容。 我可以用sizeToFit轻松地根据内容宽度调整标签宽度。 但是我不能让细胞适应标签。 这是代码 – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. arrayOfStats = @[@"time:",@"2",@"items:",@"10",@"difficulty:",@"hard",@"category:",@"main"]; } – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection: (NSInteger)section{ return [arrayOfStats count]; } – (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ return CGSizeMake(??????????); } – (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ return 1; } – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView […]

添加圆angular和投影到UICollectionViewCell

所以我已经通过添加第二个视图添加阴影的各种职位,但我仍然无法得到它的工作,如果我想将其添加到UICollectionViewCell 。 我subclassed UICollectionViewCell ,这里是我的代码,我添加各种UI元素的单元格的内容视图,并添加阴影到图层: [self.contentView setBackgroundColor:[UIColor whiteColor]]; self.layer.masksToBounds = NO; self.layer.shadowOffset = CGSizeMake(0, 1); self.layer.shadowRadius = 1.0; self.layer.shadowColor = [UIColor blackColor].CGColor; self.layer.shadowOpacity = 0.5; [self.layer setShadowPath:[[UIBezierPath bezierPathWithRect:self.bounds] CGPath]]; 我想知道如何添加圆angular和阴影到UICollectionViewCell 。

从UICollectionView获取单元格的屏幕位置

这不是解释如何解决这个问题的问题。 首先要认识到的是UICollectionView是从UIScrollViewinheritance而来的 – 所以使用滚动视图的内容进行标准查找是最好的解决scheme。 这是我正在处理的问题: 我有一个UICollectionView在每个单元中有不同的项目 – 以及不同types的单元格。 我需要select一个单元格,以使单元格中的图像的效果显现为展开并占据整个屏幕。 我如何扩展是另一个职位。 面临的挑战是让单元格在屏幕上的位置,以便animation部分从哪里开始有一个参考点。 所以,为了方便获取这些信息 – 请考虑以下代码: 首先注意: UICollectionView *picturesCollectionView; DrawingCell cell; // -> instanceof UICollectionViewCell with custom items. // first, get the list of cells that are visible on the screen – you must do this every time // since the items can change… This is a […]

UICollectionView只调用didSelectItemAtIndexPath如果用户双击,不会调用时,用户单击

我有一个关于屏幕大小的UICollectionView。 它显示的UICollectionViewCells与collectionView的大小相同。 每个单元格都有一个UIImage,它是单元格的大小。 CollectionView具有分页function,所以本质上它是一个全屏的照片幻灯片,用户可以滑过。 问题是这样的 -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath只在用户用手指敲击单元格或长按一个手指然后释放时才被调用。 它似乎没有单击select的默认行为。 我还没有对CollectionView手势识别器进行任何更改,因此无法find解决此问题的解决scheme。

用xib创buildUICollectionViewCell子类

我想创build一个UICollectionViewCell子类与链接一个xib,我有这样做:我已经创build一个新的xib文件,我已经添加一个UICollectionViewCell ,然后我创build了这个子类文件: @interface MyCell : UICollectionViewCell @property (weak, nonatomic) IBOutlet UILabel *label; @end 另外我已经在文件所有者自定义类中MyCell在界面生成器中的MyCell类,我已经添加了一个UILabel ,然后在我的UICollectionView viewDidLoad我这样做: [self.collectionView registerClass:[MyCell class] forCellWithReuseIdentifier:@"MyCell"]; UINib *cellNib = [UINib nibWithNibName:@"MyCell" bundle:nil]; [self.collectionView registerNib:cellNib forCellWithReuseIdentifier:@"MyCell"]; 以及在这个: – (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath { MyCell *cell = (MyCell*)[cv dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath]; cell.label.text = @"Cell Text"; return cell; } 但是这不起作用,我收到这个错误: *** Terminating app due […]

UICollectionView更新单个单元格

我正在尝试更新UICollectionView的单个单元格,具体UICollectionView ,我只是试图更新由cell.imageView引爆的特定单元格中的图像。 [self.collectionView reloadData]不是一个真正的select,因为它使整个集合视图闪光。 [self.collectionView beginUpdates]不是[self.collectionView beginUpdates]的东西。 我知道我可以使用: [self.collectionView performBatchUpdates:^{ //do something } completion:nil]; 我不完全确定要在完成块中放置什么来更新某个单元格的imageView 。 这一切都是在didSelectItemAtIndexPath内部完成的。我也没有使用NSFetchedResultsController 。 有任何想法吗?

dynamic大小UICollectionView单元格

1)我怎样才能实现如图所示与UICollectionView ? 2)我试过-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath方法&传递不同的大小,但它留下单元格之间的空间。 我可以清空这些空间吗? 我想为每个细胞不同的高度和宽度 电stream输出: 。

UICollectionView添加UICollectionCell

当我尝试把UICollectionCell UICollectionView Interface Builder中的UICollectionView中时,我不能把它放在原因不明的地方。 单元格将不添加到UICollectionView工具栏 我在用: iOS SDK 6.0 XCode 4.5.1 我不使用Storyboard