通过nib添加到UICollectionViewCell contentView [英] adding to UICollectionViewCell contentView via nib

查看:125
本文介绍了通过nib添加到UICollectionViewCell contentView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过xib将UICollectionViewCell的子视图添加到contentView?因为我认为这是正确的方法吗?我想当我通过xib拖放UI然后它被放入视图而不是contentView

Is there a way to add subviews of a UICollectionViewCell to a contentView via xib? Because I think this is the right way to do so right? I think when I drag and drop UI via xib then it is dropped into the view instead of the contentView

推荐答案

当你拖动时将任何视图拖放到UICollectionViewCell XIB中,您将拖动到cell.contentView,而不是cell.view。

When you drag and drop any Views into UICollectionViewCell XIB, you're dragging to cell.contentView, not cell.view.

请检入didSelect,您将看到所有子视图

Please check in didSelect, you will see all subviews

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    MyCell *cell = (MyCell*)[collectionView cellForItemAtIndexPath:indexPath];
    NSArray *views = [cell.contentView subviews];
    NSLog(@"Select %@",views);
}

这篇关于通过nib添加到UICollectionViewCell contentView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆