我是UICollectionView
的新手,当我尝试以编程方式添加UICollectionViewCell
时,我一直遇到特定错误。UICollectionView和UICollectionViewCell IndexPath错误
在我的应用程序中,我有一个UIViewController
持有UIView
。在这个UIView
的上半部分有一些物体,下半部分有UIScrollView
。这UIScrollView
持有UICollectionView
。
我试图定制UICollectionViewCell
s添加到了UICollectionView
编程,我不断收到此错误:
[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'
我试着从有点类似线程几乎每一个解决方案,但没有奏效。
下面是我认为是产生问题的代码:
- (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;
}
我可以张贴任何被请求的详细信息!
UICollectionView继承自UIScrollView,因此您可能不需要将它放在另一个滚动视图中。 – Caleb 2013-04-24 00:30:59