我試圖在UITableviewCells上實施輕掃手勢,因此當用戶向右滑動時,我希望細胞移動到具有動畫效果的表格底部(就像iphone中的CLEAR應用程序)。我已經提到這個鏈接http://www.cocoacontrols.com/platforms/ios/controls/jtgesturebasedtableviewdemo,並試圖實現它。下面是我的代碼,我至今當狀態是「正確的」將細胞移動到UITableView底部時,用動畫效果向右滑動
- (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];
}
所以你可以看到當國家是正確的,我想實現它,但我不理解如何有一個動畫嘗試影響。所以朋友們,我請求通過此代碼並幫助我。
問候 蘭吉特
您好朋友,有什麼建議嗎? – Ranjit 2012-08-07 06:49:42