- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewFlowLayout *myLayout=[[UICollectionViewFlowLayout alloc]init];
myLayout.scrollDirection=UICollectionViewScrollDirectionHorizontal;
[self.collectionView setCollectionViewLayout:myLayout animated:YES];
UIImageView *recipeImageView=[[UIImageView alloc]initWithFrame:CGRectMake(35, 100, 250, 250)];
recipeImageView.layer.borderColor = [UIColor redColor].CGColor;
recipeImageView.layer.borderWidth = 8.0;
[self.view addSubview:recipeImageView];
NSString *selectedRecipeImageFileName = [self.getName objectAtIndex:indexPath.row];
UIImage *selectedRecipeImage = [UIImage imageNamed:selectedRecipeImageFileName];
recipeImageView.image = selectedRecipeImage;
}
我正在使用集合視圖。首先,我按下任何圖像,然後在視圖上顯示UIImageView
。如果我按下其他圖像,那麼該圖像將再次出現。此時它正常工作。之後,我想擁有它,所以如果我按下空白處,然後圖像視圖隱藏。請給我一些想法。如何在UICollectionView中按下視圖時關閉UIImageView
使用UIGestureRecognizerDelegate後,哪個委託方法將會調用 – 2014-09-24 06:15:03
我編輯了我的答案,請檢查。 – teach 2014-09-24 07:18:04
好的,謝謝bro非常感謝。非常感謝 – 2014-09-24 08:31:07