Loading a Collection View Cell from storyboard (instead of from nib with registerNib)

Viewed 7182

In Xcode 5.0.2 I'm trying to recreate Michael Lehman's "Collection View" example for his video tutorial Learning To Build Apps For iPhone And iPad (password protected on Safari; the chapter 5).

Michael loads a Collection View Cell from a nib file with the following code (here the full version of his ExploreUICollectionView/ViewController.m):

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.myCollectionView.delegate = self;
    self.myCollectionView.dataSource = self;

    self.cellData = [[NSMutableArray alloc]init];

    for(int i=0; i < 100; i++)
    {
        [self.cellData addObject:[NSString stringWithFormat:@"#%d", i+1]];
    }

    UINib *cellNib = [UINib nibWithNibName:@"CVCell"
                                    bundle:nil];
    [self.myCollectionView registerNib:cellNib
            forCellWithReuseIdentifier:@"CVCell"];
}

I however would like not to create a separate nib file for the cell, but drag a View to the Main_iphone.stroryboard and Main_ipad.storyboard, give it a "Storyboard ID" if needed and then (somehow) use it in myCollectionView.

My question is which methods should I call then please?

I can not use a nibWithNibName and registerNib:forCellWithReuseIdentifier here.

UPDATE: rdelmar's advice has worked (thanks!):

enter image description here

1 Answers
Related