I'm new to iOS programming. Im trying to create use a UICollectionView to display a grid of images. I followed this tutorial: http://www.youtube.com/watch?v=ijAzOIRhhzA and executed the following steps:
- Placed the UICollectionView in Xcode into my view
- Class not set to anything
- Created a outlet property for this UICollectionView in my view controller and declared the view controller as the datasource and delegate of the UICollection view as follows:
@interface appViewController : ViewController < UICollectionViewDelegate,UICollectionViewDataSource> @end
- Set the layout property as "flow" and the scroll direction as horizontal
- Created a xib (view) deleted the default view and placed a UICollectionViewCell and filled it with a UIImage (set the identifier of the UICollectionViewCell to "appCell"
- Created a class (subclassing UICollectionViewCell) and created an outlet for the UIImage
- Class, XIB all named the same - appNameCellCollectionViewCell (.h, .m, .xib)
- In the viewDidLoad of the viewController put the following code:
[self.outletUICollectionView registerNib:[UINib nibWithNibName:@"appCellCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"appCell"];
- Implemented the numberOfItemsInSection, numberOfSectionsInCollectionView, cellForItemAtIndexPath in the viewController as follows: -(appCellCollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ appCellCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"appCell" forIndexPath:indexPath]; cell.appCellImage.image = [set image]; return cell; }
I know I'm supposed to set the datasource and delegate of the outlet to self in the view controller but I'm not sure where exactly to set that. I tried doing that in the view did load, above and below the step 8 code but no diff. I get a black area instead of the UICollectionView.
I checked that the UIImage is present and everything. I guess I'm missing something please help me !!
Thanks