我正在尝试在 UITableviewCells 上实现滑动手势,所以当用户向右滑动时,我希望单元格移动到具有动画效果的表格底部(就像 iphone 中的 CLEAR 应用程序一样)。我已经提到了这个链接 http://www.cocoacontrols.com/platforms/ios/controls/jtgesturebasedtableviewdemo,并试图实现它。以下是我到目前为止在状态“正确”时尝试过的代码
- (void)gestureRecognizer:(JTTableViewGestureRecognizer *)gestureRecognizer commitEditingState:(JTTableViewCellEditingState)state forRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableView *tableView = gestureRecognizer.tableView;
[tableView beginUpdates];
if (state == JTTableViewCellEditingStateLeft)
{
// An example to discard the cell at JTTableViewCellEditingStateLeft
[self.rows removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
}
else if (state == JTTableViewCellEditingStateRight)
{
***NSString *selectedString = [self.rows objectAtIndex:indexPath.row];
[self.rows removeObjectAtIndex:indexPath.row];
//[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
// withRowAnimation:UITableViewRowAnimationLeft];
NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];
[tableView moveRowAtIndexPath:selectedIndexPath toIndexPath:[NSIndexPath indexPathForRow:[self.rows count]-1 inSection:0]];
[self.rows insertObject:selectedString atIndex:[self.rows count]];
[tableView insertRowsAtIndexPaths:[NSArray
arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]]
withRowAnimation:UITableViewRowAnimationBottom];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];***
}
[tableView endUpdates];
// Row color needs update after datasource changes, reload it.
[tableView performSelector:@selector(reloadVisibleRowsExceptIndexPath:) withObject:indexPath afterDelay:JTTableViewRowAnimationDuration];
}
因此,您可以看到状态何时正确,我正在尝试实现它,但我不了解如何产生动画效果。所以朋友们,我请求请通过此代码并帮助我。
问候兰吉特