CollectionViewアプリを作成しています。ここで、JSON文字列を介してサーバーからデータをフェッチしています。私のワークフローは次のとおりです
コレクションビューセルをProjectVCollectionViewCell.h、.m、.xibとして作成しました。
.hのコードは-
@interface ProjectCollectionViewCell:UICollectionViewCell
@property(weak、nonatomic)IBOutlet UIImageView * projectImage;
@property(weak、nonatomic)IBOutlet UILabel * projectLabel;
@終わり
.mのコードはデフォルトであり、上記の2つの変数を合成します。.xibには、画像ビューとラベルを含むコレクションビューセルがあります(上記のクラスをコレクションビューセルにリンクし、識別子名を「projectCell」としてリンクしました。
- そのViewControllerのコードは、collectionViewを含み、次のとおりです。
ViewController.mの内部のコードは
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section{
return [projectList count];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
ProjectCollectionViewCell *cell = (ProjectCollectionViewCell *)[cv dequeueReusableCellWithReuseIdentifier:@"projectCell" forIndexPath:indexPath];
cell.projectLabel.text = @"";//Here i am getting issue
//cell.projectLabel.text = [[NSString alloc] initWithString:[[projectList objectAtIndex:indexPath.row] objectForKey:@"albumName"]];
return cell;
}
上記のコードでcell.projectlabelは私に問題を与えています
[UICollectionViewCell projectLabel]: unrecognized selector sent to instance 0x75f0fb0
2013-02-07 20:08:17.723 Sample[3189:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionViewCell projectLabel]: unrecognized selector sent to instance 0x75f0fb0'
*** First throw call stack:
セルの値は問題ありません。NSLogとコードヒントを使用して、「。」の後にprojectLabelも取得していることを確認しました。しかし、これではラベルフィールドの値を設定できません。だから私を助けてください。