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];
}
状態が正しいことを確認できるように、私はそれを実装しようとしていますが、アニメーション効果を持たせる方法がわかりません。だから友達、私はこのコードを読んで私を助けてくださいとお願いします。
よろしくランジット