从tableView作为标题的“新tableview”中的选定行



我的TableView中有数据。我使用滑动动作。当我从左到右滑动时,我可以选择按" bearbeiten"。通过单击" bearbeiten"新的TableView打开。

此新TableView的导航控制器的标题应与挥动单元格相同。

我以这种方式尝试过:

1.创建清单 2.将数据添加到此列表 3.为segue做准备 4.将列表的第一个条目推到新的ViewController 5.添加导航。标题和数据

但行不通。我做错了什么?

mycode:

第一个TableView

....
List<string> wordnewvc = new List<string>();
....
    public UIContextualAction ContextualDefinitionAction(int row)
    {
        var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal, "Bearbeiten", (ReadLaterAction, view, success) => {
                                                                wordnewvc.Add(words[row]);
                                                                secondViewController controller = this.Storyboard.InstantiateViewController("secondViewController") as secondViewController;
                                                                this.NavigationController.PushViewController(controller, true);
                                                            });
        action.BackgroundColor = UIColor.Orange;
        return action;
    }

    public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
    {
        base.PrepareForSegue(segue, sender);
        var secondViewController = segue.DestinationViewController as secondViewController;
        secondViewController.firma = wordsnewvc[0];
    }

第二ViewController

        public string firma
    {
        get;
        set;
    }
    public secondViewController (IntPtr handle) : base (handle)
    {
    }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        NavigationItem.Title = firma;
    }

您混合了Navigation PushSegue

解决方案1:导航推

方法PrepareForSegue不需要。

var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal, "Bearbeiten", (ReadLaterAction, view, success) => {
    secondViewController controller = this.Storyboard.InstantiateViewController("secondViewController") as secondViewController;
    controller.firma = wordsnewvc[0];
    this.NavigationController.PushViewController(controller, true);
});

解决方案2:SEGUE

var action = UIContextualAction.FromContextualActionStyle(UIContextualActionStyle.Normal, "Bearbeiten", (ReadLaterAction, view, success) => {
    this.PerformSegue(identifierInStoryboard, null);
});
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
{
     if(segue.Identifier == identifierInStoryboard)
     {
         var secondViewController = segue.DestinationViewController as secondViewController;
         secondViewController.firma = wordsnewvc[0];
     }  
}

相关内容

  • 没有找到相关文章

最新更新