简体   繁体   中英

Why the Collection Cell doesn't show on the collectionView?

I am new to IOS , and I want to implement the album by collectionView in IOS.

I create the View (name: AITCameraCollectionBrowser.xib ) like the following picture.

在此处输入图片说明

and create the another AITPhotoCell.xib file like the following picture.

在此处输入图片说明

I want the cell show on the collectionView .

But both the button and collectionView in the AITCameraCollectionBrowser doesn't show.

And I don't know why the View doesn't show anything ?

The following code is in viewDidLoad for AITCameraCollectionBrowser.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    [self.collectionview registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];

    self.collectionview.dataSource = self;
    self.collectionview.delegate = self;

    [self.collectionview addSubview:_collectionview];


    UINib *nib = [UINib nibWithNibName:@"AITPhotoCell" bundle:nil];

    [self.collectionview registerNib:nib forCellWithReuseIdentifier:[AITPhotoCell reuseIdentifier]];
}

Why the button and collectionView in the AITCameraCollectionBrowser doesn't show.

Do I lack for something in viewDidLoad ?

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(75,75)];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
[self.collectionview setCollectionViewLayout:flowLayout];
[self.collectionview registerNib:[UINib nibWithNibName:@"AITPhotoCell" bundle:nil] forCellWithReuseIdentifier:@"CellIdentifier"];

Try This.. its Working.. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM