0

私はs を初めて使用します。プログラムで sUICollectionViewを追加しようとすると、特定のエラーが発生し続けます。UICollectionViewCell

私のアプリにUIViewControllerは、UIView. この 内UIViewには、上半分にいくつかのオブジェクトがあり、下半分にはUIScrollView. これUIScrollViewは を保持しUICollectionViewます。

UICollectionViewCellカスタムを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;
}

リクエストされた情報を投稿できます!

4

1 に答える 1

2

エラー メッセージを読みます。メソッドの名前が間違っているため、メソッドがありません。

[myViewController collectionView:cellForItemAtIndexPath:]:認識できないセレクターがインスタンスに送信されました0x1e01f5e0

つまり、collectionView:cellForItemAtIndexPath:メソッドが欠落しています。メソッドの定義を見ると、実際にそれを呼び出していることがわかりますmyCollectionView:cellForItemAtIndexPath:

于 2013-04-23T23:45:43.973 に答える