我有一个应用程序,如果用户输入数据,行将用该数据更新
我可以使用一个单一的按钮说“删除”吗?点击它会立即删除表格 View 中的所有行。?
最佳答案
是的,你可以做到。首先从数据源中删除所有数据,然后重新加载表。对于前。 -
[yourArrayDataSource removeAllObjects];
[yourTable reloadData];
为删除行设置动画 - 在 IBAction
方法中执行此操作并将其链接到您的 UIButton
。只要您按下按钮,您就会看到一个流畅的动画效果,让您的所有行都淡出。
-(IBAction)deleteRows
{
[yourTable beginUpdates];
for(int i=0; i<[yourArrayDataSource count]; i++)
{
indexPath = [NSIndexPath indexPathForRow:i inSection:0];
[self.searchResTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
[yourTable endUpdates];
}
您可以在此处使用各种动画-
UITableViewRowAnimationBottom
UITableViewRowAnimationFade
UITableViewRowAnimationMiddle
UITableViewRowAnimationNone
UITableViewRowAnimationRight
UITableViewRowAnimationTop
关于iphone - 在 uitableview 中删除行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8006113/