MonoTouch.Foundation.MonoTouchException An Objective-C exception was thrown. Name: NSInternalInconsistencyException

I seem to be getting this issue when I run an iOS app in Xamarin.

MonoTouch.Foundation.MonoTouchException has been thrown

Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Could not load NIB in bundle: ’NSBundle ... (loaded)' with name ‘RouteMeViewController'

      

I am trying to replace GoogleMapsViewController with RouteMeViewController using Objective C library and Binder in the application I was given to work with. My AppDelegate looks like this:

namespace ExampleApp.iOS
{
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{

    UIWindow window;
    RouteMeViewController viewController;

    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    {
        window = new UIWindow (UIScreen.MainScreen.Bounds);

        viewController = new RouteMeViewController ();
        window.RootViewController = viewController;
        window.MakeKeyAndVisible ();

        return true;
    }

}

      

RouteMeViewController

namespace ExampleApp.iOS
{
public partial class RouteMeViewController : UIViewController
{

    RMMapView MapView { get; set; }

    public RouteMeViewController () : base ("RouteMeViewController", null)
    {
    }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();

        MapView = new RMMapView(View.Frame, new RMOpenStreetMapSource().Handle);
        MapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;

        if (UIScreen.MainScreen.Scale > 1.0)
            MapView.AdjustTilesForRetinaDisplay = true;

        Add (MapView);
    }

}

      

}

Any help or guidance is greatly appreciated, thanks!

+3


source to share


1 answer


You seem to be missing a designer file in the resources of your solution. Even if you create controls and views programmatically, you need a designer file to pull them into, even if it's just an empty designer file. For IOS, you can use Xcode to do this. You can create .xib files. They will be compiled on your device, and the resulting file has a .nib extension. Make sure the target .xib file is the correct viewController for your project, otherwise you will still get an error.



Hope this helps. Good luck!

+2


source







All Articles