Reputation: 1954
I am new to UICollectionView
s, and I keep running into a specific error when I try to add UICollectionViewCell
s programmatically.
In my app, I have one UIViewController
that holds a UIView
. Within this UIView
, there are a few objects on the top half, and the bottom half holds a UIScrollView
. This UIScrollView
holds a UICollectionView
.
I am attempting to add custom UICollectionViewCell
s to the UICollectionView
programmatically, and I keep getting this error:
[myViewController collectionView:cellForItemAtIndexPath:]: unrecognized selector sent to instance 0x1e01f5e0
2013-04-23 16:19:02.726 myAppName[28121:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[myViewController collectionView:cellForItemAtIndexPath:]: unrecognized selector sent to instance 0x1e01f5e0'
I've tried almost every solution from somewhat similar threads, but nothing has worked.
Here's the code that I believe is producing the problem:
- (UICollectionViewCell *)myCollectionView:(UICollectionView *)myCollectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableArray *data = [self.dataArray objectAtIndex:indexPath.section];
NSString *cellData = [data objectAtIndex:indexPath.row];
static NSString *cellIdentifier = @"cvCell";
UICollectionViewCell *cell = [myCollectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
UILabel *myCellTextLabel = (UILabel *)[cell viewWithTag:100];
[myCellTextLabel setText:cellData];
return cell;
}
I can post any more information that is requested!
Upvotes: 0
Views: 945
Reputation: 243156
Read the error message; you're missing a method, because you've named your method incorrectly.
[myViewController collectionView:cellForItemAtIndexPath:]:
unrecognized selector sent to instance0x1e01f5e0
That means your collectionView:cellForItemAtIndexPath:
method is missing. And if you look at the definition of your method, you'll see you actually called it myCollectionView:cellForItemAtIndexPath:
.
Upvotes: 2