I am trying to replicate the iOS9 feature where you can drag to select multiple photos, or UICollectionViewCells: https://i.ytimg.com/vi/LZRTu3B5zlY/maxresdefault.jpg
I saw one answer here, but as a beginner iOS and objective-c developer, I couldn't figure out what to do.
I have also tried to work from this question, but I couldn't get anything to select.
I tried some code, but couldn't get any response at all.
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
self.startPoint = [touch locationInView:self.collectionView];
self.selectionBox = CGRectMake(self.startPoint.x, self.startPoint.y, 0, 0);
[self.collectionView setNeedsDisplay];
}
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.collectionView];
_selectionBox.size.width = currentPoint.x - (self.selectionBox.origin.x);
_selectionBox.size.height = currentPoint.y - (self.selectionBox.origin.y);
self.selectionBox = CGRectMake(self.startPoint.x, self.startPoint.y, 0, 0);
// select all the cells in this selectionBox area
[self.collectionView setNeedsDisplay];
}
Any pointers on how to code this? Thanks very much.