Im using touch event in the tableview to select the tableview cell.I want to tableview to scroll slowly to select tableview cell.And when Im reaching last visible cell inside the frame i want to cell to scroll one by one.Below my code scrolls but not accurate.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
self.scrollEnabled = YES;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
self.scrollEnabled = YES;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
self.scrollEnabled = NO;
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self];
NSIndexPath *swipedIndexPath = [self indexPathForRowAtPoint:location];
NSLog(@"%ld",(long)swipedIndexPath.row);
NSLog(@"%f",location.y);
NSArray *visibleRows = [self indexPathsForVisibleRows];
NSIndexPath *firstPath = visibleRows[0];
NSIndexPath *secondPath = visibleRows[1];
CGRect firstRowRect = [self rectForRowAtIndexPath:firstPath];
[self scrollToRowAtIndexPath:(firstRowRect.origin.y > self.contentOffset.y ? firstPath : secondPath) atScrollPosition:UITableViewScrollPositionTop animated:YES];
UITableViewCell *cell = [self cellForRowAtIndexPath:swipedIndexPath];
cell.textLabel.text = @"Checked";
[self reloadRowsAtIndexPaths:@[swipedIndexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
can have any other option or what Im doing wrong here