Forum Xamarin.iOS

Custom UINavigationBar error (-barPositionForBar:!) since updating for iOS 7

My app has a custom UINavigationController with a custom UINavigationBar.

It's always worked fine but since updating Xamarin Studio and XCode to fully support iOS7 it throws the following error in the simulators and on iOS 7 devices.

It happens when I do anything on the navigation controller, such as pushing a view or changing the background colour.

Any suggestions? Do I need to create my own fully working delegate for the navigation bar?

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: Unexpected bar sending delegate -barPositionForBar:! <MyApp.CustomNavigationBar: 0x7c053780; baseClass = UINavigationBar; frame = (0 0; 320 44); opaque = NO; gestureRecognizers = <NSArray: 0x7c054a20>; layer = <CALayer: 0x7c0534c0>>
  at at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_bool (intptr,intptr,intptr,bool)
  at MonoTouch.UIKit.UINavigationController.PushViewController (MonoTouch.UIKit.UIViewController viewController, Boolean animated) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UINavigationController.g.cs:183

The bit of code in my custom navigation controller, where I'm creating the custom navigation bar.

public override UINavigationBar NavigationBar {

    get {

         if (_customNavigationBar == null)
             _customNavigationBar = new CustomNavigationBar ();


         return (UINavigationBar) _customNavigationBar;




  • I've decided to ditch my custom navigation bar approach and add a custom view to the navigation controller instead.

Sign In or Register to comment.