如何实现点击不同的CollectionViewCell,弹出的View的内容不同
1个回答
2016-01-23
展开全部
在新弹出的view中实现了如下方法:
- (void)initContent:(int)index
{
self.collectionCellStore = [CollectionCellStore sharedStore];
self.DetailImage.image = ((CollectionEntity*)self.collectionCellStore.cellItems[index]).image;
self.DetailText.text = ((CollectionEntity*)self.collectionCellStore.cellItems[index]).title;
[self.view setNeedsDisplay];
}
然后在cell被点击时调用:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detailViewController = [[DetailViewController alloc] init];
[detailViewController initContent:indexPath.row];
[self.navigationController pushViewController:detailViewController animated:YES];
}
- (void)initContent:(int)index
{
self.collectionCellStore = [CollectionCellStore sharedStore];
self.DetailImage.image = ((CollectionEntity*)self.collectionCellStore.cellItems[index]).image;
self.DetailText.text = ((CollectionEntity*)self.collectionCellStore.cellItems[index]).title;
[self.view setNeedsDisplay];
}
然后在cell被点击时调用:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detailViewController = [[DetailViewController alloc] init];
[detailViewController initContent:indexPath.row];
[self.navigationController pushViewController:detailViewController animated:YES];
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询