Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何为UICollectionViewCell使用UITableViewCellAccessoryCheckmark单元格样式_Ios_Uicollectionview - Fatal编程技术网

Ios 如何为UICollectionViewCell使用UITableViewCellAccessoryCheckmark单元格样式

Ios 如何为UICollectionViewCell使用UITableViewCellAccessoryCheckmark单元格样式,ios,uicollectionview,Ios,Uicollectionview,我现在使用的是UICollectionView方法,目前已将设备照片集成到uicollectionviewcell中。我想为UICollectionViewCells添加单元格样式方法 UICollectionView是否有任何可用的单元格样式,如UITableViewCellAccessoryCheckmark?您可以创建UICollectionViewCell类并初始化要在单元格中显示的内容,如 CollectionViewCustomCell.h #import <UIKit/UIK

我现在使用的是
UICollectionView
方法,目前已将设备照片集成到uicollectionviewcell中。我想为UICollectionViewCells添加单元格样式方法


UICollectionView是否有任何可用的单元格样式,如
UITableViewCellAccessoryCheckmark

您可以创建UICollectionViewCell类并初始化要在单元格中显示的内容,如

CollectionViewCustomCell.h

#import <UIKit/UIKit.h>

@interface CollectionViewCustomCell : UICollectionViewCell

@property (retain, nonatomic) UILabel* label;
@property (retain, nonatomic) UIImageView *myImageView;


@end



#import "CollectionViewCustomCell.m"

@implementation CollectionViewCustomCell
@synthesize label,myImageView;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        label = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, frame.size.width, frame.size.height)];
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor = [UIColor blackColor];
        label.font = [UIFont boldSystemFontOfSize:35.0];
        label.backgroundColor = [UIColor whiteColor];

        [self.contentView addSubview:label];;

        myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 70, 70)];
        myImageView.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:myImageView];
    }
    return self;
}

@end
在cellForItemAtIndexPath:

   - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
    {
        CollectionViewCustomCell *customcell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
        customcell.label.text = @"Text";
        customcell. myImageView.image = yourImage;

        return customcell;
    }

这只是一个想法。您可以将其他子视图添加到集合视图单元格。

Collectionviewcell没有任何单元格样式。但是您可以定制CollectionViewCell以满足您的需要。谢谢。您能告诉我如何定制CollectionViewCell或任何链接吗?您可以看到我的答案。它只是一个想法,如何可以定制您的细胞。你也看到了,非常感谢,我会尽力让你知道的
   - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
    {
        CollectionViewCustomCell *customcell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
        customcell.label.text = @"Text";
        customcell. myImageView.image = yourImage;

        return customcell;
    }