title: How to get the collection cell in other function in ios?
body: <p>I have UICollectionView on which contains so many custom cells.I have a long press gesture on it when user long press then cells start shaking &amp; delete button is added on them.When i press the delete button then cell is removed from collection view.</p>
  
  <p><strong>Code for long press.</strong></p>
  
  <pre><code>-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
  {
      p = [gestureRecognizer locationInView:self.collection_view];
      NSIndexPath *indexPath = [self.collection_view indexPathForItemAtPoint:p];
      if (gestureRecognizer.state != UIGestureRecognizerStateEnded)
      {
          return;
      }
  
      if (indexPath == nil)
      {
          NSLog(@"couldn't find index path");
      }
      else
      {
          [[NSUserDefaults standardUserDefaults]setValue:@"yes" forKey:@"longPressed"];
          [self.collection_view reloadData];
      }
      if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
          NSLog(@"UIGestureRecognizerStateEnded");
          //Do Whatever You want on End of Gesture
      }
      else if (gestureRecognizer.state == UIGestureRecognizerStateBegan){
          NSLog(@"UIGestureRecognizerStateBegan.");
          //Do Whatever You want on Began of Gesture
      }
  
      pgr
      = [[UIPanGestureRecognizer alloc]
         initWithTarget:self action:@selector(handePanPress:)];
      // To detect after how many seconds you want shake the cells
      pgr.delegate = self;
      [self.collection_view addGestureRecognizer:pgr];
  
      //show the done button here
      navButtonDone = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(navBtnDone:)];
      self.navigationItem.rightBarButtonItem = navButtonDone;
  
  }
  </code></pre>
  
  <p>when long gesture start i also add the right button on nav bar on press of nav bar button i stop animation &amp; remove the delete button.I able to remove delete button in iPhone 5s but not in iPhone 6.</p>
  
  <p><strong>below is code for that</strong></p>
  
  <pre><code>- (IBAction)navBtnDone:(id)sender
  {
          if([[[NSUserDefaults standardUserDefaults]valueForKey:@"longPressed"] isEqualToString:@"yes"])
          {
              [[NSUserDefaults standardUserDefaults]setValue:@"no" forKey:@"longPressed"];
              [_deleteButton removeFromSuperview];
              [self.collection_view reloadData];
              [self.collection_view removeGestureRecognizer:pgr];
              self.navigationItem.rightBarButtonItem=nil;
          }
  }
  </code></pre>
  
  <p>Here i have just added  <code>[_deleteButton removeFromSuperview];</code> how can i get cell in each function &amp; remove the delete button.</p>