Please let me re-stress, I am on MvvmCross 6.4.2. I'm currently upgrading a very old project.
I'm getting the error "Trying to show a page without a PageViewController, this is not possible!". According to the source, this is because my PageViewController is null.
I'm not sure why this is, because I've set my pager views and viewmodels up like in the playground sample (the big change in 6.4.2. appears to add attribute support for PageViewControllers).
The PageViewController I want to show (embedded in another ViewController via Container View, for clarity):
[MvxFromStoryboard("Main")]
//[MvxRootPresentation(WrapInNavigationController = true)]
public partial class MyPageViewController : MvxPageViewController<MyPagingViewModel>
And my first page:
[MvxPagePresentation(WrapInNavigationController = false)]
public partial class Page1View : MvxViewController<Page1ViewModel>
{
public Page1View() : base()
{
}
public Page1View(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
UIButton myButton = new UIButton(UIButtonType.System);
myButton.Frame = new CGRect(25, 25, 300, 150);
myButton.SetTitle("Hello, World!", UIControlState.Normal);
}
}
And my pages ViewModel:
public class Page1ViewModel : MvxNavigationViewModel
{
public Page1ViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigationService) : base(logProvider, navigationService)
{
}
}
I override ShowPageViewController in my custom MvxIosViewPresenter to see what variables are passed in:
protected override Task<bool> ShowPageViewController(UIViewController viewController, MvxPagePresentationAttribute attribute, MvxViewModelRequest request)
The viewController is of type Page1View. Shouldn't it be MyPageViewController though if the method is called ShowPageViewController?
I use a command to navigate to the pages, just like in the playground:
private Task ShowInitialViewModels()
{
var tasks = new List<Task>();
tasks.Add(NavigationService.Navigate<Page1ViewModel>());
return Task.WhenAll(tasks);
}
So what could be going wrong?