Search code examples
iosxamarinmvvmcross

Adding childViewController to MvxTabBarViewController doesn't present view


I have created a popover menu for my ios application using a UIViewController presented on a view using

currentViewController.addChildViewController(modalViewController)

and adding it as a subview

currentViewController.addSubview(modalViewController.view)

and this works for most of my views, but we use MvxTabBarViewController to present a number of other views and the above technique doesn't work when i attempt to add it to the currently SelectedViewController, i assume because this is a wrapped class and presented in a different way.

Has anyone attempted something similar? or know a way to gain access to the underlying viewController within selectedViewController.

SelectedViewController.TopViewController & SelectedViewController.VisibleViewController

are visible at run time but not accessible

EDIT: if I call currentViewController.addChildViewController(modalViewController) and move to another tab and then back to the one i added the viewControlelr to, the popover window appears on a black background, which confirms my suspicion that it is to do with how tabbed viewControllers are presented

EDIT2: I should also point out this popover menu i used to service a button on the navigation bar of the tabBarView as a root rather then something in when of the tabbed view controllers themselves and doesn't have an associated xib


Solution

  • Just to say, I solved this problem, by calling ViewWillAppear() myself before adding modalViewController.view to the sub views of the tabbed view i wished it to appear in. bypassing addChildViewController all together.

    Note if you do this you are responsible for the life cycle of the view and must dispose if it when it is no longer needed.