Cha*_*ndu 2 iphone xcode objective-c uitableview ios
我有一个应用程序,如果用户输入数据,行将使用该数据更新
我可以使用单个按钮说"删除",单击该按钮会立即删除tableview中的所有行.
是的,你可以这样做.首先从数据源中删除所有数据,然后重新加载表.对于前者 -
[yourArrayDataSource removeAllObjects];
[yourTable reloadData];
Run Code Online (Sandbox Code Playgroud)
要动态删除行 - 在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];
}
Run Code Online (Sandbox Code Playgroud)
你可以在这里使用各种动画 -
UITableViewRowAnimationBottom
UITableViewRowAnimationFade
UITableViewRowAnimationMiddle
UITableViewRowAnimationNone
UITableViewRowAnimationRight
UITableViewRowAnimationTop
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5286 次 |
| 最近记录: |