1

I'm using a NavigationController and I want its UINavigationBar's GetPositionForBar() method to always return UIBarPosition.TopAttached. As I'm using UINavigationController it's not possible to change the NavigationBar delegate, so I'm not sure how to proceed.

I tried a lot of things, one o them was:

public class CustomNavigationController : UINavigationController, IUINavigationBarDelegate
{
    [Export ("positionForBar:")]
    public UIBarPosition GetPositionForBar(IUIBarPositioning barPositioning)
    {
        return UIBarPosition.TopAttached;
    }
}

But it's not working. How can I do this? I'm using Xamarin/Monotouch.

ernewston
  • 923
  • 6
  • 22

2 Answers2

0

I finally created my own UINavigationBar manually and added it at the top of the View, this way I can change the delegate.

ernewston
  • 923
  • 6
  • 22
0

Did you set WeakDelegate? Something like

public class MyTableViewController : UITableViewController {
    public override void ViewDidLoad() {
        _searchController = new UISearchController();
        _searchController.SearchBar.WeakDelegate = this;
    }

    [Export ("positionForBar:")]
    public UIBarPosition GetPositionForBar(IUIBarPositioning barPositioning)
    {
        return UIBarPosition.TopAttached;
    }
}
Lee Richardson
  • 8,331
  • 6
  • 42
  • 65