objective-c exception thrown. name nsinvalidargumentexception reason pushing the same viewcontroller

DuraiHDuraiH USMember ✭✭
edited February 2017 in Xamarin.iOS

I am using MVVM light I usually use view model based navigation but for same reason I tried to push the navigation controller from iOS side instead from View model

base.NavigationController.PushViewController(new SampleViewController(base.Handle), false);

I got the following error message

But when I peeked into the navigation controller I only see the current view controller in the stack.
Here is the screenshot

I am wondering why it happens ?

Best Answer

  • DuraiHDuraiH US ✭✭
    Accepted Answer

    I stopped doing the navigation natively and I tried navigation using view models thats the way to go

    so below here I got the reference to navigation

             /// <summary>
            /// Gets the MVVM Navigation reference 
            /// </summary>
            public NavigationService GlobalNavigation
            {
                get
                {
                    return (NavigationService)ServiceLocator.Current.GetInstance<INavigationService>();
                }
            }
    

    I called NavigateTo like we do inside the view model for navigation

    GlobalNavigation.NavigateTo("")

Answers

  • DuraiHDuraiH USMember ✭✭
    Accepted Answer

    I stopped doing the navigation natively and I tried navigation using view models thats the way to go

    so below here I got the reference to navigation

             /// <summary>
            /// Gets the MVVM Navigation reference 
            /// </summary>
            public NavigationService GlobalNavigation
            {
                get
                {
                    return (NavigationService)ServiceLocator.Current.GetInstance<INavigationService>();
                }
            }
    

    I called NavigateTo like we do inside the view model for navigation

    GlobalNavigation.NavigateTo("")

  • Michael_ShapiroMichael_Shapiro USMember ✭✭✭

    @DuraiH - I also use mvvm light and trigger navigation from the view model. I was wondering if you know how to customize the transition from one screen to another? I believe when doing native navigation (with segues, for instance) you can control how the new screen appears. Is there a way to do it with mvvm light?

    Thank you,
    mike

  • DuraiamuthanHarikrishnanDuraiamuthanHarikrishnan GBMember ✭✭
    edited March 2017

    1

  • Michael_ShapiroMichael_Shapiro USMember ✭✭✭

    @DuraiamuthanHarikrishnan - that was very informative response :smiley:

Sign In or Register to comment.