0

Is anyone having a problem with Xcode 6 when adding a Collection View Controller to storyboards and naming the custom class?

-> I drag a Collection View Controller to my scene -> add a new file -> name it "LCCollectionViewController" with a subclass of UICollectionViewController.

Next, I select the Collection View Controller in storyboard, and name the custom class LCCollectionViewController in the identity inspector.

Problem: The document outline still shows the name as Collection View Controller.

Code just in case: 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
iDev
  • 478
  • 1
  • 3
  • 24
  • I can't really remember much of objective-c now but aren't you supposed to specify that it is a subclass of UICollectionViewController? ( `@implementation LCCollectionViewController: UICollectionViewController`) – martskins Oct 22 '14 at 17:17
  • it allows..! mention how to did you add new file.? – Avis Oct 22 '14 at 17:34
  • @lascort the subclass is in the header – iDev Oct 22 '14 at 17:45

1 Answers1

0

I encountered same bug in xcode6. What helped me was to change subclass to any other viewcontroller subclass you have set up already (perhaps create temporary one if none is available) and then change it back to LLCollectionViewController.

Viktor Kucera
  • 6,177
  • 4
  • 32
  • 43