我已经加入另一UICollectionViewCell到我UICollectionView如图所示:麻烦与UICollectionViewCell
每一个被连接到一个不同的类黄一个被连接到一个称为的ImageCell和蓝色一个类被连接到一个名为TwitterCell的类。图像单元应该显示一个Instagram的图片与UIImageView(现在BTW工作正常)。不过,我想在TwitterCell下添加其他单元,它应该用UILabel显示用户的Twitter推文。这里是我的代码现在:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
ImageCell *cell = (ImageCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"imageCell"
forIndexPath:indexPath];
NSURL *url = [self imageUrlForEntryAtIndexPath:indexPath];
//NSLog(@"%@", url);
[cell.imageView setImageWithURL:url];
cell.backgroundColor = [UIColor whiteColor];
TwitterCell *tweetCell = (TwitterCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"twitterCell" forIndexPath:indexPath];
return cell;
return tweetCell;
}
这里是我到底想要什么形象(记住一切都按时间排序发布):
你问这个问题之前(http://stackoverflow.com/questions/18284955/how-would-you-add-two-different-uicollectionviewcells),并且显然没有任何尝试改变你的代码的基础上我的答案在那里。 – rdelmar