I've added a horizontal UIPanGestureRecognizer to my tableviewcell to pan a subview of the cell, like the way the ios7 mail app does to reveal delete and more options and this works as expected
- (IBAction)slideCell:(UIPanGestureRecognizer *)sender
{
CGPoint locationOfPan = [sender locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:locationOfPan];
TestCell *cell = (TestCell *)[self.tableView cellForRowAtIndexPath:indexPath];
if (sender.state == UIGestureRecognizerStateChanged) {
CGPoint translation = [sender translationInView:self.tableView];
[cell.view setCenter:CGPointMake(cell.view.center.x + translation.x, cell.view.center.y)];
[sender setTranslation:CGPointMake(0, 0) inView:self.tableView];
}
}
What I would also like to do is add a UIAttachmentBehavior with an anchor point to each of my UITableViewCells so that when I pan the cell.view
horizontally I feel some resistance and then when I let go, the view in the cell that was panned springs back to it's original anchor position on the x axis, is this possible to do with UIDynamics?
Also can I set one side of the cell as a boundary which prevents a user from panning the contained view beyond it?