rpt*_*thi 0 iphone objective-c uitableview
我正在从表视图中删除单元格,它实现了滑动删除,遵循我正在使用的代码:
#pragma mark -
#pragma mark Table View Data Source Methods
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
[addTagTableView setEditing:editing animated:YES];
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
//Updating the data-model array and deleting the row
- (void)tableView:(UITableView *)tv commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// If row is deleted, remove it from the list.
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self.tagsArray removeObjectAtIndex:indexPath.row];
[self.addTagTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
Run Code Online (Sandbox Code Playgroud)
这让我可以实现刷卡删除,但是我想简单的减去红色按钮删除,如何实现呢?
- (void)viewDidLoad {
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
Run Code Online (Sandbox Code Playgroud)
使用此代码,您的应用中会有一个编辑按钮.如果按此按钮,"红色减号"会自动出现:)
| 归档时间: |
|
| 查看次数: |
4719 次 |
| 最近记录: |