【发布时间】:2014-07-09 06:00:46
【问题描述】:
我想在一个视图控制器中放置多个 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;
} }
上面的代码正在运行,但它仅适用于一个集合视图,我使用断点对其进行了调试,因此它进入了第一个返回语句。所以另一部分代码甚至没有运行。那么如何解决这个问题。 提前谢谢你:)
【问题讨论】:
-
你找到什么了吗,我现在也有同样的问题:(
标签: ios objective-c ipad uicollectionviewcell uicollectionreusableview