Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
716 views
in Technique[技术] by (71.8m points)

xamarin.ios - MvvmCross Using a modal ViewController from a Tab

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

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 -

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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?

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;
        }

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.

Hope that helps

Stuart


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...