MvvmCross 使用选项卡中的模态 ViewController [英] MvvmCross Using a modal ViewController from a Tab

查看:15
本文介绍了MvvmCross 使用选项卡中的模态 ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索过 SO &MvvmCross & 的其他地方模态的,但现有的一个答案对我们没有帮助.

I've searched on SO & elsewhere for MvvmCross & Modal, but the one existing answer isn't helping us.

我们正在使用 MonoTouch &MvvmCross,这似乎是一个相当强大的组合.但是,我们在导航方面遇到了一些问题,我们正在逐步解决这些问题!当前的问题是-

We're developing a cross-platform app using MonoTouch & MvvmCross, which seems to be pretty powerful combination. However, we're having a few issues with the navigation, which we're gradually cracking! The current problem is -

应用程序使用 TabBarController 运行,每个选项卡都可以导航到更多级别 - 这很好用.然而,客户端希望其中一个选项卡上的开始"按钮显示一个模态视图(隐藏其他所有内容,尤其是选项卡栏),然后它有自己的级别,其工作方式与 UINavigationController 相同,具有能力随时弹回 tabBarController.

The app runs with a TabBarController, and each tab has navigation to further levels - this works fine. The client however wants the "Start" button on one of the tabs to bring up a modal view (which hides everything else, especially the tab bar), which then has its own levels working in the same manner as a UINavigationController, with the ability to pop back to the tabBarController at any time.

我们已经设法调出一个模态视图,但我们被困在从这里加载新视图并弹出.

We've managed to bring up a single modal view, but we're stuck on loading new views from here and popping back out.

任何帮助/建议表示赞赏!

Any help/advice appreciated!

推荐答案

我认为您要做的是自定义演示者,以便它将您的 UIViewController 包装在 UINavigationController 中 - 然后以模态方式呈现该 UINavigationController?

I think what you're looking to do is to customise the presenter so that it wraps your UIViewController within a UINavigationController - and then modally presents that UINavigationController?

为了实现这一点,@DeapSquatter 最近的 Pull 请求中的代码可能会有所帮助 -https://github.com/slodge/MvvmCross/pull/9 - 我认为你可以使用他的 modal nav presenter 以达到你想要的效果:

To achieve this, the code in the recent Pull request from @DeapSquatter might help -https://github.com/slodge/MvvmCross/pull/9 - I think you can use his modal nav presenter in order to achieve the effect you are looking for:

        if (view is IMvxModalTouchView)
        {
            if (_currentModalViewController != null)
                throw new MvxException("Only one modal view controller at a time supported");

            var newNav = new UINavigationController();
            newNav.PushViewController(view as UIViewController, false);

            _currentModalViewController = view as UIViewController;

            PresentModalViewController(newNav, true);
            return;
        }

mvvmcross 的架构在这里是有意可扩展和可配置的——虽然我们包含了一些基本的 Presenter 类,但人们很可能希望在逐个应用程序的基础上自定义不同视图的呈现方式.除了最简单的演示应用程序之外,我预计大多数 mvvmcross 触控应用程序都将附带一个自定义演示器.

The architecture of mvvmcross is deliberately extensible and configurable here - while we include a few basic Presenter classes, it's very likely that people are going to want to customise how different views get presented on an app-by-app basis. Beyond the simplest of demo apps, I anticipate that most mvvmcross apps on touch will ship with a custom presenter inside.

希望有帮助

斯图尔特

这篇关于MvvmCross 使用选项卡中的模态 ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆