Clancey / FlyoutNavigation

Other
95 stars 87 forks source link

Fix for ViewWillAppear not firing in some cases #74

Closed ianvink closed 9 years ago

ianvink commented 9 years ago

This is probably a hack fix below, but in my case when ViewWillAppear does not fire I use it to ensure it does.

(I use FlyoutNavigation.cs in the AppDelegate)

  public override void ViewWillAppear (bool animated)
  {
     DoSetup ();
     base.ViewWillAppear (animated);
  }

  public void DoSetup ()
  {

     if (!hasSetup) {
        hasSetup = true;
        CGRect navFrame = navigation.View.Frame;
        navFrame.Width = menuWidth;
        if (Position == FlyOutNavigationPosition.Right)
           navFrame.X = mainView.Frame.Width - menuWidth;
        navFrame.Location = CGPoint.Empty;
        navigation.View.Frame = navFrame;
        View.BackgroundColor = NavigationTableView.BackgroundColor;
        var frame = mainView.Frame;
        setViewSize ();
        SetLocation (frame);
        navigation.OnSelection += NavigationItemSelected;
     }
  }

  public override void ViewDidAppear (bool animated)
  {
     base.ViewDidAppear (animated);
     DoSetup ();
     var frame = mainView.Frame;
     setViewSize ();
     SetLocation (frame);
  }
Clancey commented 9 years ago

When are you seeing it not fire? Is it nested inside another ViewController?

ianvink commented 9 years ago

Yes, I have a Class that inherits from FlyoutNavigation.cs

ianvink commented 9 years ago

I probably missed calling base somewhere, but for now I'm good.

Clancey commented 9 years ago

Subclassing shouldn't cause it not to fire. However if you have var parent = new UIViewController(); var menu = new FlyoutNavigation(); parent.View.Add(menu.View);

That could easily cause it. You need to add the Child to the parent with parent.AddChildviewcontroller(menu);

ianvink commented 9 years ago

Strange that it is happening now. I have it in several dozen published apps (wonderful by the way!). Xamarin may have changed some internals.

Clancey commented 9 years ago

Any way you can create a small sample showing the issue? I am curious.

ianvink commented 9 years ago

i'll see what I can do. I noticed my fix doesn't work if a modal advert if pushed after the screen loads so these is something there.

On Sun, Mar 29, 2015 at 6:31 PM, James Clancey notifications@github.com wrote:

Any way you can create a small sample showing the issue? I am curious.

— Reply to this email directly or view it on GitHub https://github.com/Clancey/FlyoutNavigation/issues/74#issuecomment-87508758 .