【问题标题】:How can I segue between two xib files in xamarin?如何在 xamarin 中的两个 xib 文件之间切换?
【发布时间】:2015-08-31 03:08:31
【问题描述】:

我是 Xamarin 的新手,我正在开发一个应用程序。我也在使用 mvvmCross。如何在按钮单击时在两个视图之间切换?通常我使用情节提要,所以就像控制+单击并拖动以将其连接起来一样简单。我的第二个想法是做类似的事情:

PerformSegue(identifier, sender);

但是,当我打开 xib 以编辑界面时,我无法设置标识符。

所以我有两个 xib 文件,HomeView.xib 和 SecondView.xib。以及两个c 锐文件HomeView.cs 和SecondView.cs。 HomeView 有一个按钮,我已经控制 + 将 IBAction 拖到 c 中,并且有一个方法 buttonPressed() 我希望在其中进入我的 secondView。

partial void ButtonPressed (Foundation.NSObject sender){
        //Insert Code to segue to SecondView.
    }

谢谢:)

编辑:我找到了这段代码:

 NSBundle.MainBundle.LoadNib("SecondView", this, null);

这很有效,但是 segue 仍然更可取,因为它看起来更好

【问题讨论】:

  • 能不能不做:this.PerformSegue("SecondView", this); (?)

标签: ios xcode xamarin segue xib


【解决方案1】:

在故事板中创建 2 个转场,并为每个转场设置不同的标识符。

然后使用

this.PerformSegue("TargetSegueIdentifier", this);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-27
    • 1970-01-01
    • 2015-12-24
    • 2015-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多