Setup looks like this:

LoginView MvxViewController
   MainView MvxTabBarViewController
      -Tab 1 
         - View1 (MvxViewController)
      -Tab 2 
         - View1 (MvxViewController)
      -Tab 3 
         - View1 (MvxViewController)

On View1 a I have a Tableview (List), will be filled always differently - depends on the tab.

Everything works fine so far. The problem I face now is, that when I'm in View1 and press the "Back" Button on the NavigationController I will get back to the "LoginView" instead the "MainView" (Rootview where the tabs are).

I found following command this.NavigationController.PopToRootViewController(true); but I didn't find the right place to use it. (If it's even the right way)

I used this project to get the idea behind https://github.com/slodge/MvvmCross-Tutorials/blob/master/Sample%20-%20CirriousConference/Cirrious.Conference.UI.Touch/Views/TabBarController.cs

Any help appreciated!

EDIT:

I solved the problem now, by removing following code (commented section removed):

public class MyPresenter : MvxModalSupportTouchViewPresenter, ITabBarPresenterHost
{
    public MyPresenter(UIApplicationDelegate applicationDelegate, UIWindow window)
        : base(applicationDelegate, window)
    {
    }

    protected override UINavigationController CreateNavigationController(UIViewController viewController)
    {
        var toReturn = base.CreateNavigationController(viewController);
        toReturn.NavigationBarHidden = false;
        return toReturn;
    }

    public ITabBarPresenter TabBarPresenter { get; set; }

    public override void Show(IMvxTouchView view)
    {
        //if (TabBarPresenter != null && view != TabBarPresenter)
        //{
        //    TabBarPresenter.ShowView(view);
        //    return;
        //}
        base.Show(view);
    }
}

I still don't understand the purpose of this code as it's making troubles. By removing it, everything works fine. (Code was from the example, to find here: https://github.com/slodge/MvvmCross-Tutorials/blob/0f313e3be66b06c110f587b653b9b0c831fb7164/Sample%20-%20CirriousConference/Cirrious.Conference.UI.Touch/ConferencePresenter.cs)

有帮助吗?

解决方案

Generally you use a CustomPresenter for this type of logic - see N=25 in http://mvvmcross.wordpress.com for one example.

Your custom presenter can do things like:

For more on custom presenters, see https://github.com/slodge/MvvmCross/wiki/Customising-using-App-and-Setup#custom-presenters and http://slodge.blogspot.co.uk/2013/06/presenter-roundup.html


This article might be especially useful - http://deapsquatter.blogspot.co.uk/2013/06/custom-presenter-for-uitabbarcontroller.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top