在将集合视图控制器添加到情节提要并命名自定义类时,是否有人遇到 Xcode 6 问题?
-> 我将一个集合视图控制器拖到我的场景中 -> 添加一个新文件 -> 使用 UICollectionViewController 的子类将其命名为“LCCollectionViewController”。
接下来,我在 storyboard 中选择 Collection View Controller,并在身份检查器中命名自定义类 LCCollectionViewController。
问题:文档大纲仍然显示名称为 Collection View Controller。
代码以防万一:LCCollectionViewController.m
@interface LCCollectionViewController ()
{
NSArray *theImages;
}
@end
@implementation LCCollectionViewController
static NSString * const reuseIdentifier = @"Cell";
- (void)viewDidLoad {
[super viewDidLoad];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
moonImages = [NSArray arrayWithObjects:@"image1.gif", @"image2.gif", @"image3.gif", @"image4.gif", nil];
}
#pragma mark <UICollectionViewDataSource>
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [moonImages count];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
// Configure the cell
UIImageView *theImageView = (UIImageView *)[cell viewWithTag:100];
theImageView.image = [theImages objectAtIndex:indexPath.row];
return cell;
}
@end