How can I segue between two xib files in xamarin?

亡梦爱人 提交于 2019-12-25 08:45:23

问题


I'm new to Xamarin and I'm working my way through an app. I'm also using mvvmCross. How can I segue between two views on button click? Normally I use storyboard so that's as simple as control+click and drag to hook it up. My second thought was to do something like:

PerformSegue(identifier, sender);

However, there's no way for me to set the identifier when i open the xib up to edit the interface.

So I have two xib files, HomeView.xib and SecondView.xib. As well as two c sharp files HomeView.cs and SecondView.cs. HomeView has a button and I have control+dragged the IBAction into the c sharp and have a method buttonPressed() where I wish to segue into my secondView.

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

Thanks :)

EDIT: I found this piece of code:

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

Which works, however a segue would still be preferable as it looks nicer


回答1:


Create 2 segues in your storyboard and set different identifier to each segue.

Then use

this.PerformSegue("TargetSegueIdentifier", this);



来源:https://stackoverflow.com/questions/32303464/how-can-i-segue-between-two-xib-files-in-xamarin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!