抛出了MonoTouch.Foundation.MonoTouchException,抛出了Objective-C异常。名称:NSInternalInconsistencyException

时间:2014-12-15 21:40:06

标签: c# ios xamarin.ios xamarin route-me

每当我在Xamarin中运行我的iOS应用程序时,我似乎都会遇到此问题。

MonoTouch.Foundation.MonoTouchException has been thrown

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

我正在尝试使用Objective C库替换一个带有RouteMeViewController的GoogleMapsViewController,并在我给予工作的应用程序中使用Binder。我的AppDelegate看起来像这样:

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);
    }

}

}

非常感谢任何帮助或指导,谢谢!

1 个答案:

答案 0 :(得分:3)

您的解决方案资源中似乎缺少设计器文件。即使您以编程方式创建控件和视图,也需要一个设计器文件,即使它只是一个空的设计器文件,也需要将它们绘制出来。对于IOS,您可以使用XCode。您可以使用.xib扩展名创建文件。它们将在您的设备上编译,生成的文件扩展名为.nib。确保.xib文件的目标是项目的正确viewController,否则你仍然会收到错误。

我希望这会有所帮助。祝你好运!