gpt4 book ai didi

c# - Xamarin iOS - 屏幕流程

转载 作者:行者123 更新时间:2023-11-29 05:18:07 26 4
gpt4 key购买 nike

我在应用程序中围绕 UIViewControllers 提供了导航流选项

A->B->C

A->D

在C中,有一个选项允许用户D。C和D没有通过segues相互连接,但都来自A。

我尝试过从 C 提出 D 并忽略 C,但它让我回到 B。在android中,我通常会做两个popbackstack并显示D。我如何在 Xamarin iOS 中执行此操作?

最佳答案

如果您从 C 到 D 使用 PushViewController,您可以使用 NavigationController.PopToRootViewController(true); 轻松返回到 A;

如果从C到D使用PresentViewController,可以先呈现D,然后在C中调用PopToRootViewController

这是C中的代码:

    UIViewControllerD controlD =new UIViewControllerD();

Action action = () => {
NavigationController.PopToRootViewController(true);
};

myButton.TouchUpInside += (sender, e) => {

//1. navigate to D
//NavigationController.PushViewController(new UIViewControllerD(), true);

//2. present D
NavigationController.PresentViewController(controlD, true, action);
};

返回时D中的代码:

    myButton.TouchUpInside += (sender, e) => {

//1. navigate to root ViewControll
//NavigationController.PopToRootViewController(true);

//2. Dismiss D
this.DismissViewController(true,null);

};

我上传了我的样本here你可以检查一下。有任何问题请随时问我。

关于c# - Xamarin iOS - 屏幕流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58967102/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com