【发布时间】:2017-12-02 03:21:20
【问题描述】:
我正在尝试创建自己的自定义 UICollectionView 首先,我在 Storyboard 中添加了一个 CollectionView。
PURPLE 的原因是因为一开始我的控制器根本没有显示。因此,我将 CELL 设为灰色,并注意到在将 Collection View 设为紫色后,该项目不可见。
我正在尝试使用独特的图像和标签填充我的收藏视图。这是我旅程的开始。
这是我的 CollectionViewController
#import "LoadZoneViewController.h"
#import "ZoneCollectionViewCell.h"
@interface LoadZoneViewController ()
@end
@implementation LoadZoneViewController
static NSString * const reuseIdentifier = @"Cell";
- (void)viewDidLoad {
[super viewDidLoad];
// Register cell classes
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark <UICollectionViewDataSource>
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
#warning Incomplete implementation, return the number of sections
return 12;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of items
return 12;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
// Configure the cell
return cell;
}
#pragma mark <UICollectionViewDelegate>
@end
我也定义了一个自定义 UICollectionViewCell,但我认为我应该担心在我解决了这个问题之后。当前的问题只是标签没有出现,视图底部有一个滚动条,但我没有看到 12 个标签。
【问题讨论】:
-
尝试在 viewdidload 中添加
self.collectionView.delegate = self和self.collectionView.dataSource = self -
好的,我试过了。仍然没有结果。
标签: ios objective-c uicollectionview