我第一次创建 UIControlerView 似乎从未激活过代表。请告诉我哪里出错了。
谢谢!顺便说一句,我通过从情节提要中拖动来创建 IBOutlet ......
。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