我的TableView
中有数据。我使用滑动操作。当我从左向右滑动时,我可以选择按“Bearbeiten”。点击“Bearbeiten”即可打开新的TableView
。
此新TableView
的导航控制器的标题应与刷过的单元格具有相同的名称。
我试过这种方式:
1.创建一个列表
2.将数据添加到此列表中
3.准备Segue
4.将列表的第一个条目推送到新ViewController
5.添加带有数据的Navigation.title
但它不起作用。我做错了什么?
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;
}
答案 0 :(得分:0)
您混合了Navigation Push
和Segue
不需要方法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);
});
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];
}
}