I am using Xamarin Forms and would like to set a native UIBarButtonItem in the iOS navigation bar.
I've created a custom PageRenderer and overridden the ViewDidLoad() method to add a Done button on the right of the navigationItem. The code is being executed but the UIBarButtonItem doesn't appear. I've also tried executing this in ViewWillAppear and ViewDidAppear but no Done button appears.
Can anyone help me with why this doesn't work?
[assembly: ExportRendererAttribute(typeof(OTContentPage), typeof(OTContentPageRenderer))] namespace OurGalaxyX.iOS { public class OTContentPageRenderer : PageRenderer { public OTContentPageRenderer() : base() { } public override void ViewDidLoad() { base.ViewDidLoad(); if (this.NavigationController != null) { var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (sender, args) => { this.NavigationController.PopViewController(true); }); doneButton.TintColor = UIColor.Yellow; this.NavigationController.TopViewController.NavigationItem.RightBarButtonItem = doneButton; } } } }