Xamarin IOS登录移动到另一个页面

时间:2018-05-23 20:24:44

标签: ios xamarin

我是Xamarin IOS的​​新手。我无法找到登录后如何转到其他页面的解决方案。就像Android一样。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

无论您的loginPage是否包含在情节提要内,最好的方法是在登录后更改Window.RootViewController中的AppDelegate

在LoginPage内部

if (login)
{
    AppDelegate app = UIApplication.SharedApplication.Delegate as AppDelegate;
    app.changeOtherPage();
}

内部AppDelegate

public void changeOtherPage ()
{
    //if the page is contained in storyboard
    UIStoryboard sb = UIStoryboard.FromName("SBName",null);
    OtherPage callHistory = sb.InstantiateViewController("OtherPage") as OtherPage;
    Window.RootViewController = callHistory;

    //if the page is not contained in storyboard
    Window.RootViewController = new OtherPage();
}