Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 删除编辑按钮上的UICollectionView单元格_Objective C_Uitableview_Parse Platform_Uicollectionview_Uicollectionviewcell - Fatal编程技术网

Objective c 删除编辑按钮上的UICollectionView单元格

Objective c 删除编辑按钮上的UICollectionView单元格,objective-c,uitableview,parse-platform,uicollectionview,uicollectionviewcell,Objective C,Uitableview,Parse Platform,Uicollectionview,Uicollectionviewcell,我正在使用UICollectionView检索存储在云数据库中的图像和标签 我现在需要一个选项,可以让我删除某个图像及其相应的标签 我正在寻找一些东西,比如位于右上角的典型iPhone“编辑”按钮,它会在手机旁边显示一个带有删除按钮的滑动动画。我知道这样的事情可以通过UITableView完成 [[self tableView] setEditing:YES animated:YES]; 但我似乎在任何地方都找不到UICollectionView的等价物 任何帮助都值得赞赏,即使它不处理从解析

我正在使用UICollectionView检索存储在云数据库中的图像和标签

我现在需要一个选项,可以让我删除某个图像及其相应的标签

我正在寻找一些东西,比如位于右上角的典型iPhone“编辑”按钮,它会在手机旁边显示一个带有删除按钮的滑动动画。我知道这样的事情可以通过UITableView完成

[[self tableView] setEditing:YES animated:YES];
但我似乎在任何地方都找不到UICollectionView的等价物

任何帮助都值得赞赏,即使它不处理从解析本身删除的问题,只需要集合视图上的编辑样式就可以了

以下是我如何填充我的单元格:

- (void)viewDidLoad
{
   [super viewDidLoad];
   [self retrieveSelectedImages];
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [imageFilesArray count];
}


-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

static NSString *cellIdentifier = @"myRoomsCell";
MyRoomsCell *cell = (MyRoomsCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];

PFObject *imageObject = [imageFilesArray objectAtIndex:indexPath.row];
PFFile *imageFile = [imageObject objectForKey:@"imageFile"];

cell.loadingSpinner.hidden = NO; //show loading spinner to indicate work is happening until the image loads
[cell.loadingSpinner startAnimating];

// UILabel *label = (UILabel*) [cell viewWithTag:5];
cell.label.text= [imageObject objectForKey:@"roomLabel"]; //set room label as the label stored on parse previously inserted by the user

cell.label.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
cell.label.textAlignment = NSTextAlignmentCenter;


[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error)
{
    if (!error) {
        cell.parseImage.image = [UIImage imageWithData:data];
        [cell.loadingSpinner stopAnimating];
        cell.loadingSpinner.hidden = YES;
    }
}];

return cell;
}

-(void) retrieveSelectedImages
{
//parse query where we search the favorites array column and return any entry where the array contains the logged in user objectid
PFQuery *getFavorites = [PFQuery queryWithClassName:@"collectionViewData"];
[getFavorites whereKey:@"selectedImage" equalTo:[PFUser currentUser].objectId];

[getFavorites findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error)
    {
        imageFilesArray = [[NSArray alloc] initWithArray:objects];
        [roomsCollection reloadData];
    }
}];
}

请查看此答案,并提供大量代码供您尝试:

基本上,没有苹果提供的方法来做到这一点

还有一些非常好的图书馆。我个人最喜欢的是,也是退房

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    [[Singleton sharedSingleton].selectedProfileArray removeObjectAtIndex:indexPath.row];
    [selectCollectionView reloadData];
}