0
在我的應用程序中,我逐一捕獲圖像,我在最後一個索引處顯示「添加更多」單元格,添加新圖像時,我想要「添加更多」單元格可見,在3-4個圖像之後「添加更多」單元格被隱藏。 如何更新集合視圖,使「添加更多」單元始終可見。 謝謝:)更新集合添加新單元格時的視圖
代碼中添加圖片:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
if (indexPath.row == [imageArray count]) {
cell.ImageImg.image =[UIImage imageNamed:@"plus.jpg"];
cell.DeleteBtn.hidden=true;
[cell.ImageImg.layer setBorderColor: [[UIColor clearColor] CGColor]];
[cell.ImageImg.layer setBorderWidth: 0.5];
}
else
{
cell.DeleteBtn.hidden=false;
cell.ImageImg.image=[imageArray objectAtIndex:indexPath.row];
[cell.ImageImg.layer setBorderColor: [[UIColor blackColor] CGColor]];
[cell.ImageImg.layer setBorderWidth: 0.7];
[cell.DeleteBtn addTarget:self action:@selector(RemovePrssd:) forControlEvents:UIControlEventTouchUpInside];
}
return cell;
}
-(void)RemovePrssd:(id)sender{
UIView *senderButton = (UIView*) sender;
NSIndexPath *indexPath = [_ImageCollectionVIew indexPathForCell: (UICollectionViewCell *)[[senderButton superview]superview]];
[imageArray removeObjectAtIndex:indexPath.row];
[_ImageCollectionVIew deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == [imageArray count]) {
[email protected]"0";
[_videoController.view removeFromSuperview ];
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
}
}
顯示您的相關代碼! – Lion
你能粘貼圖片嗎? –
@Lion我添加了代碼:)請檢查 –