1 つのビュー コントローラーに複数の uicollectionview を配置したいのですが、それをストーリーボードに正常に配置しただけでなく、以下のような .m ファイルにコードがあります。
-(UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath: (NSIndexPath *)indexPath;
{
if (_collectionview.tag==2) {
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
[cell.image setImageWithURL:[NSURL URLWithString:@"http://192.168.0.104:808/Images/Image1.jpg"]placeholderImage:[UIImage imageNamed:@"0.jpg"]];
cell.label.text = [[recipes valueForKey:@"name"]objectAtIndex:0];
return cell;
}
if(_collectionview.tag==1)
{
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:jerryCellID forIndexPath:indexPath];
[cell.image1 setImageWithURL:[NSURL URLWithString:@"http://img1.wikia.nocookie.net/__cb20121123214954/tomandjerry/images/a/a8/Jerry_(3).jpg"]placeholderImage:[UIImage imageNamed:@"0.jpg"]];
cell.catlabel.text = [[recipes valueForKey:@"name"]objectAtIndex:0];
return cell;
}
else
{
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
[cell.image setImageWithURL:[NSURL URLWithString:@"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcT4RNUL18GXdQt2h9Ay4e7eHwm1lgC1BiRKrZY72Apt7b9cTViR7Q"]placeholderImage:[UIImage imageNamed:@"0.jpg"]];
cell.label.text = [[recipes valueForKey:@"name"]objectAtIndex:0];
return cell;
} }
上記のコードは実行されていますが、ブレークポイントを使用してこれをデバッグした 1 つのコレクション ビューに対してのみ機能するため、最初の return ステートメントに入ります。そのため、コードの別の部分は実行されていません.soこの問題を解決する方法. 前もって感謝します :)