ios – UICollectionView : Cells don’t seem/populate

[ad_1]

I want some assist with a uicollectionview that I have been making an attempt to implement in Goal-C/xcode: I’m unable to have the cells seem/populate the collectionview (CV).
At the moment I’m utilizing the interface builder, and a customized class for cells.
The CV is to be a large strip that could be a single row of sq. picture cells, that may be scrolled/swept by way of horizontally.
My makes an attempt at implementation outcome within the broad strip but it surely by no means populates with cells.
I’ve explored different stackoverflow threads much like this subject, the place they talk about the subclassing of cell however I used to be unable to make it work. Have additionally tried programmatic implementation and had the identical subject. Would actually respect any perception as I’ve been caught at this level for days. Beneath the code I’m utilizing, are screenshots of interface builder exhibiting completely different settings… some I do know are helpful to incorporate and I apologize if I’ve shared something ineffective.

from ViewController.h

@interface ViewController : UIViewController <UICollectionViewDelegate,UICollectionViewDataSource>

@property (weak, nonatomic)  NSMutableArray *medCollectionCells;

from ViewController.m

#import "CoolCell.h"

@property (weak, nonatomic) IBOutlet UICollectionView *medCollection;

- (void)viewDidLoad

{

    _medCollectionCells = [NSMutableArray arrayWithObjects:@"1st cell",@"2nd cell",@"3rd cell",@"4th cell",@"5th cell",@"6th cell",@"7th cell",@"8th cell",@"5th cell", nil];

    self.medCollection.delegate = self;

    self.medCollection.dataSource = self;

}

// assortment view delegate strategies

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)part
{

    return [_medCollectionCells count];

}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CoolCell *cell = (CoolCell *)[_medCollection dequeueReusableCellWithReuseIdentifier:@"MyCustomCell" forIndexPath:indexPath];

    cell.backgroundColor = [UIColor blackColor];

    return cell;

}

CoolCell.h:

#import <UIKit/UIKit.h>

@interface CoolCell : UICollectionViewCell

@property (weak, nonatomic) IBOutlet UILabel *customLabel;

@property (weak, nonatomic) IBOutlet UIImageView *customImage;

@finish

CoolCell.m:

#import "CoolCell.h"

@implementation CoolCell

@finish

Display screen Photographs

Storyboard structure

Assortment View Settings 1

Assortment View Settings 2

Cell Settings 1

Cell Settings 2

Interface Builder Shops

Grateful for any help/perception. Thanks.

[ad_2]

Leave a Reply