Mvvmcross with Xamarin iOS, is it possible to load a ViewController within a ViewController?

425 Views Asked by At

I have an MvxViewController which displays a UITableView. When the user selects an item 'ShowViewModel' is called and a new view is displayed.

My aim is to override this so that the new view is rendered within a ViewContainer on the same screen. I'm not sure how to go about this though.

I would use a SplitViewController, however I want a single TabBar/NavigationBar that stretches the whole screen. SplitViewControllers have to be set as a RootNavigationController - meaning the NavigationBars would only appear in one view.

Mockup of UI

2

There are 2 best solutions below

0
On

Create a UIView for your new View and add it as a subview to the parent ViewContainer

1
On

The best approach I have found to solve this nature of problem is to create a region service.

The region service is simply a class that keeps a Dictionary.

When you create a UIViewController you may wish to use to present a child view controller register it with the region service with a name (e.g. DetailRegion).

Then in the UIViewController class that you wish to present in that region, have some way of identifying the region in which it wants to be presented; perhaps an attribute.

You then just need to create a custom presenter to resolve the UIViewController for a given region name and take the appropriate action to display the view model.

This might sound convoluted, but I have used this model in a few projects now, and it makes my life a whole lot easier.

Thanks, Tristan