uicollection视图datail视图

时间:2013-06-23 06:51:11

标签: cocoa-touch uicollectionview

我是iphone的新手。我在我的应用程序中有一个集合视图,它工作正常,但现在我想在另一个imageview中的下一个viewcontroller中选择一个图像和我想要的图像。 - (NSInteger)collectionView:

我使用以下代码:

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return recipeImages.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"Cell";

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

    UIImageView *recipeImageView = (UIImageView *)[cell viewWithTag:100];
    recipeImageView.image = [UIImage imageNamed:[recipeImages objectAtIndex:indexPath.row]];

    return cell;
}

1 个答案:

答案 0 :(得分:0)

实施collectionView:didSelectItemAtIndexPath:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    UIImage *image = [UIImage imageNamed:[recipeImages objectAtIndex:indexPath.item]];
    // go on...
}
相关问题