2

The problem I have with the SplitView is the navigation bar... it's missing. I use a tablet presenter, like in the MVVMCross examples. When trying to add a navigation bar item, like shown in the CustomerManagement example for instance, it doesn't show.

I think it has something to do with the UINavigation controller missing, but I can't figure out how to implement it using a tablet presenter.

My views are constructed using Dialog, and my presenter is using the MvxBaseTouchViewPresenter.

Can anyone tell me how to make use of the navigation bar while using splitview and dialog?

Thanks in advance!

Stuart
  • 66,722
  • 7
  • 114
  • 165
Jvdbrink
  • 77
  • 5

2 Answers2

0

I'm not 100% clear on your UI from your description - if I've got the wrong idea, then some pictures might help.

However... basically I believe that any UI you can achieve in plain MonoTouch you should also be able to achieve in MvvmCross.

It looks like you've already worked out quite a lot of this, but just to recap:

  • When a navigation is requested
  • the system asks the Container to construct a 'View' (which is a UIViewController - not a UIView)
  • the system passes the loaded View to the Presenter
  • the Presenter can show this View however it wants to - e.g. popup, splitview, navigation child, modal, etc - and can also do other UI changes (animations, tab switches, etc)
  • when the UIView itself is loaded (in UIViewController ViewDidLoad) then the MvxView base class loads the ViewModel for the View to use.

In your example it sounds like you maybe want to specialise one of your split views so that it contains a UINavigationController - and you then want your Presenter to pass your new view to that UINavigationController for pushing.

This is just C# code - and it's just in your UI project - feel free to write it just like you would 'normal MonoTouch'.

One example of an 'advanced' presenter is the conference sample - see how it delegates the show action to the Tab Bar - https://github.com/slodge/MvvmCross/blob/vnext/Sample%20-%20CirriousConference/Cirrious.Conference.UI.Touch/ConferencePresenter.cs

Stuart
  • 66,722
  • 7
  • 114
  • 165
  • The moment I submitted my own solution, you posted your answer. In short: My splitview uses UINavigationControllers for pushing instead of setting new ViewControllers. – Jvdbrink Nov 30 '12 at 09:10
0

I've managed to answer my own question. Please correct me if my approach is wrong!

I use the same setup as in the MVVMCross examples on github. I've made a minor change to the SplitViewController:

  1. I've created two UINavigationControllers called _detailNav and _rootNav.
  2. The UINavigationController constructor allows a UIViewController to be set a RootViewController. Set a ViewController here (in the example: new EmptyViewController()).
  3. Change the two methods called: SetPrimaryView and SetSecondaryView so it uses the UINavigationController to change ViewControllers.

Example, change this: this.ViewControllers = new UIViewController[] { controller, ViewControllers[1] };

To this: _detailNav.PushViewController(controller, true);

Now the _detailNav (a UINavigationController) is used to change the view, instead of setting a new ViewControllers array in the SplitView.

Jvdbrink
  • 77
  • 5
  • thanks - would love to see a blog post - maybe with a picture :) – Stuart Nov 30 '12 at 09:09
  • also - some of the xam samples might help - e.g. the http://blog.xamarin.com/2012/02/24/mwc_2012/ app – Stuart Nov 30 '12 at 09:11
  • 1
    I currently don't have a blog :( Your examples have helped me quite a lot! The problem I had with iOS and navigation occured because I haven't done my iOS homework. A little knowledge about ViewControllers, SplitViews and UINavigationControllers helps a lot to further understand MVVMCross. – Jvdbrink Nov 30 '12 at 09:17
  • SO don't like us chatting here - chat on http://jabbr.net/#/rooms/mvvmcross - but questions on here :) – Stuart Nov 30 '12 at 09:43
  • You can always email me blog posts and I'll publish them as guest posts :) – Stuart Nov 30 '12 at 09:44