NavigationController Not Pushing

MarthughieMarthughie GBMember ✭✭
edited November 2015 in Xamarin.iOS

I have a UITabBarController, and one of the Tabbed Views within it needs to be able to navigate. I have created it therefore as a UINavigationController

public partial class NC_TabBase : UINavigationController
{

//.....
    public void RowWasSelected()
    {
            UIViewController    nextvc = new  VC_Messages ();
            this.PushViewController(nextvc,true);
    }
}

within this class when an event fires I need to navigate to another View Controller, which for now just shows an image

partial class VC_Messages : UIViewController
{
    public VC_Messages ()
    {
    }

    //==============================================================================
    public override void ViewDidLoad()
    {
        base.ViewDidLoad ();

        UIView logoView = new UIView () { BackgroundColor = UIColor.White };
        logoView.TranslatesAutoresizingMaskIntoConstraints = false;

        //-----------------------------------------------------------
        // create the view which holds the  image
        UIImageView imageView = new UIImageView() { Image = UIImage.FromFile("work-in-progress.jpg") };
        imageView.ContentMode=UIViewContentMode.ScaleAspectFit;
        imageView.TranslatesAutoresizingMaskIntoConstraints = false;

        View.Add (logoView);
        View.AddConstraints (new NSLayoutConstraint[] {
            NSLayoutConstraint.Create(logoView,NSLayoutAttribute.CenterY,   NSLayoutRelation.Equal, View,   NSLayoutAttribute.CenterY,1f,0f),
            NSLayoutConstraint.Create(logoView,NSLayoutAttribute.CenterX,   NSLayoutRelation.Equal, View,   NSLayoutAttribute.CenterX,1f,0f),
            NSLayoutConstraint.Create(logoView,NSLayoutAttribute.Width,     NSLayoutRelation.Equal, View,   NSLayoutAttribute.Width,1f, 0f),
            NSLayoutConstraint.Create(logoView,NSLayoutAttribute.Height,    NSLayoutRelation.Equal, View,   NSLayoutAttribute.Height,1f,    0f)
        });

        logoView.Add (imageView);
        logoView.AddConstraints (new NSLayoutConstraint[] {
            NSLayoutConstraint.Create(imageView,NSLayoutAttribute.CenterX,NSLayoutRelation.Equal,logoView,NSLayoutAttribute.CenterX,1f,0f),
            NSLayoutConstraint.Create(imageView,NSLayoutAttribute.CenterY,NSLayoutRelation.Equal,logoView,NSLayoutAttribute.CenterY,1f,0f),
            NSLayoutConstraint.Create(imageView,NSLayoutAttribute.Width,  NSLayoutRelation.Equal,logoView,NSLayoutAttribute.Width, 0.95f,   0f),
            NSLayoutConstraint.Create(imageView,NSLayoutAttribute.Height, NSLayoutRelation.Equal,logoView,NSLayoutAttribute.Height,1f,0f)
        });

    }

}

However, despite the RowWasSelected event firing, and neither of the two lines within throwing an exception, no Navigation takes place. The original View remains in place.

What am I missing ?

Thanks

Sign In or Register to comment.