我在 xamarin.ios 工作。下面附上代码
public override void CommitEditingStyle (UITableView tableView,UITableViewCellEditingStyle editingStyle, Foundation.NSIndexPath indexPath){
switch (editingStyle) {
case UITableViewCellEditingStyle.Delete:
// delete the row from the table
tableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
break;
case UITableViewCellEditingStyle.None:
break;
}}
当我滑动删除时它会起作用。但是,当我推送一个新的 ViewController 并返回时。没有变化。
我是 iOS 新手。希望有人能提供帮助。
最佳答案
我猜你刚刚刷新了界面。这还不够。 使用代码
// remove the item from the underlying data source
tableItems.RemoveAt(indexPath.Row);
// delete the row from the table
tableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
同时,您应该从数据源中删除相应的数据。
关于ios - 当我在 Xamarin.iOS 中删除 TableView 的特定行时。 tableview 变成了以前的样子。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51889110/