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

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

问题描述

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

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.

感谢任何帮助/建议!

推荐答案

我认为您想要做的是自定义演示器,以便它将 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天全站免登陆