ios - 当我在 Xamarin.iOS 中删除 TableView 的特定行时。 tableview 变成了以前的样子。

标签 ios xamarin.ios

我在 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/

相关文章:

c# - MonoTouch 对话框的 UITableView。如何处理水龙头?

ios - 我可以对NSComparisonResult使用'> ='吗?

ios - 同步 Realm 对象服务器连接完成以及后续 Realm 对象使用情况

iOS 带阴影的圆形 UITextField

.net - 为 Xamarin 的 Mono Touch/Android 框架编译 AWS SDK (.NET)

xamarin - `Xamarin.Insights.Initialize(string)' 已过时

ios - QuickLook ShouldOpenUrl 委托(delegate)方法未触发

ios - MFMailComposeViewController 获取邮件正文

iOS CAMImagePickerCameraViewController 在 iOS 10.3.1 中崩溃

iphone - MonoTouch 更改 Tab 顺序或检测 Tab 以手动转到下一个字段