本文介绍了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 -我认为您可以使用他的模态导航演示者,以达到您想要的效果:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:30