我试图在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