I have a UICollectionView. It scrolls horizontally, has only a single row of items, and behaves like a paging UIScrollView. I\'m making something along the lines of the Safari t
I know this has an answer already but I implemented this in a slightly different way that doesn't require dispatching after a set interval.
In your delete method you would do a check to determine if the last item was being deleted. If it was call the following:
if(self.selection == self.assets.count-1 && self.selection != 0){
isDeleting = YES;
[collection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:self.selection-1 inSection:0] atScrollPosition:UICollectionViewScrollPositionLeft animated:YES];
}
Assuming selection is the selected item you are deleting. This will scroll to the item to the left of it. Note the if statement checking that this is not the only item. If it were the call would crash as there is no -1 row.
Then you can implement the following method which is called when the scroll animation is complete. I simply set isDeleting to no in the deleteObjectInCollection method and it all seems to work.
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView{
if(isDeleting){
[self deleteObjectInCollection];
}
}
I hope this helps.