my first time creating a UIControlerView and it seems that the delegates are never activated. Please tell me where I am going wrong.
Thank you!
By the way I created the IBOutlet by dragging from the storyboard…
.h
#import <UIKit/UIKit.h>
@interface CollectionController : UIViewController<UICollectionViewDelegate,UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *controllerTableView;
@end
.m
#import "CollectionController.h"
#import "CollectionVIewCell.h"
@interface CollectionController ()
@end
@implementation CollectionController
- (void)viewDidLoad
{
[super viewDidLoad];
[[self controllerTableView]setDelegate:self];
[[self controllerTableView]setDataSource:self];
// Do any additional setup after loading the view.
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 10;
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier=@"Cell";
CollectionVIewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
cell.labelDisplay.text=@"hi";
//set up data in images
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Try hooking up your
UICollectionView‘s delegate and data source in the xib rather than in code.