NavigationRenderer > NavigationBar.Items empty on iOS7 (throws IndexOutOfBoundsException)

Shane000Shane000 USMember ✭✭✭

I'm accessing the navigation Item just fine in iOS8 but there isn't one in iOS7. I can't update the NavigationBar manually because it's controlled by the NavigationPage controller. Is this a xamarin thing or an iOS7 thing? Any idea how I get around this? Works great on iOS8

    public class MyNavigationPageRenderer : NavigationRenderer
    {
        UIBarButtonItem _savedLeftIconBarButtonItem;
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var navigationPage = (MyNavigationPage)Element;
            var navBar = this.NavigationBar;
            UINavigationItem item;
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {

                item = navBar.Items[0];
            }
            else
            {
                // What do I do here???
                item = navBar.Items[0]; // crashes on 7.1
            }
       }
   }

Posts

Sign In or Register to comment.