我有一個ImagePickerController
的照片和視頻。當我從相機中選取照片或視頻時,我將其作爲圖像顯示在CollectionView
中。在這一步,一切正常。我添加了一個Bool
變量checkVideo
,以瞭解我在單元格中顯示的圖像,來自視頻或照片的圖像。 checkVideo
更改值,當我使用imagePickerController的視頻或照片。我想添加一個新的圖像與來自視頻的圖像的播放圖標。這是我的代碼:如何爲CollectionViewCell設置兩個圖像視圖
- (CustomCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath];
if (checkVideo == YES) {
UIImageView *playVideoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
playVideoImageView.image = playImg;
[cell addSubview:playVideoImageView];
cell.imageViewCell.image = arrayForImages[indexPath.row];
checkVideo = NO;
} else {
cell.imageViewCell.image = arrayForImages[indexPath.row];
}
NSLog(@"check video %@", checkVideo ? @"YES" : @"NO");
return cell;
}
你在哪裏設置了'checkVideo'標誌?它是單個變量還是「數組」? – Mathews