title: some of the collection view cell didSelectItemAtIndexPath not working
body: <p><img src="https://i.stack.imgur.com/fckKM.png" alt="enter image description here"></p>
  
  <p>I have been struck with this for a while. my error is for some cells in the time table didSelectItemAtIndexPath is not calling. i have kept a break point on the method and when i click for some cells the method is not being called. What could be the problem. Pls see the below code</p>
  
  <pre><code>- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section;
  {
  
         return 25;
  
  }
  
  - (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *) collectionView
  {
  
            return 1;
  
  }
  
  -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  {
      NSLog(@"item clicked");
      CGRect rect = [collectionData layoutAttributesForItemAtIndexPath:indexPath].frame;
  
      UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
      UIViewController* vc = [storyboard instantiateViewControllerWithIdentifier:@"note"];
  
      pc = [[UIPopoverController alloc] initWithContentViewController:vc];
  
      [pc presentPopoverFromRect:rect inView:collectionData
        permittedArrowDirections:UIPopoverArrowDirectionAny
                        animated:YES];
      NSLog(@" The index path is %@", indexPath);
  
  }
  
  - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  {
  
  
      // we're going to use a custom UICollectionViewCell, which will hold an image and its label
      Cell *myCell = [collectionData dequeueReusableCellWithReuseIdentifier:@"TableCell"
                                                         forIndexPath:indexPath];
  
      if (indexPath.row &lt; 20 || indexPath.row == 22 )
      {
      myCell.roomLabel.text = [NSString stringWithFormat:@"{%ld,%ld}", (long)indexPath.row, (long)indexPath.section];
  
      NSLog(@"cell no %ld" ,(long)indexPath.row );
      myCell.subjectLabel.text =@"English";
      myCell.cellView.backgroundColor= [UIColor grayColor];
  
      [myCell.redXbuttonOutlet addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
  
      if(isLongPressed)
      {
          [myCell.redXbuttonOutlet setHidden:NO];
      }
      else
      {
         [myCell.redXbuttonOutlet setHidden:YES];
      }
      }
       else
      {
  
          myCell.userInteractionEnabled = NO;
        [myCell.redXbuttonOutlet setHidden:YES];
         myCell.cellView.backgroundColor= [UIColor whiteColor];
        myCell.subjectLabel.text =@"";
         myCell.roomLabel.text = @"";
  
      }
      return myCell;
  
  }
  -(void)buttonPressed:(id)sender
  {
      NSLog(@"Button");
      UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"Delete session" message:@"Do you want to delete this session" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
      [alert show];
  }
  </code></pre>