0

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

Deepak
  • 1,278
  • 3
  • 15
  • 23
  • Why do you need to use touches delegate when you can easily do it using UITableView Delegate methods.. Check these links http://stackoverflow.com/questions/2797165/uitableviewcell-checkmark-change-on-select and https://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html – iphonic Apr 11 '14 at 06:31
  • I know to how to checkmark a tableview with didselect..But i use touch moved such that i can get touched indexpath.But when i reach last cell the tableview should scroll automatically one by one cell.Such that i can checkmark the upcoming cells just by holding the the frame bottom – Deepak Apr 11 '14 at 06:39

0 Answers0