首页 > 编程语言> > c#-已引发MonoTouch.Foundation.MonoTouchException引发了Objective-C异常.名称:NSInternalInconsistencyException
c#-已引发MonoTouch.Foundation.MonoTouchException引发了Objective-C异常.名称:NSInternalInconsistencyException
作者:互联网
每当我在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库和Binder用RouteMeViewController替换GoogleMapsViewController.我的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);
}
}
}
非常感谢您的帮助或指导,谢谢!
解决方法:
似乎您的解决方案资源中缺少设计器文件.即使您以编程方式创建控件和视图,也需要一个需要在其中绘制设计器的文件,即使它只是一个空的设计器文件也是如此.对于IOS,您可以使用XCode.您可以创建带有.xib扩展名的文件.它们将在您的设备上编译,并且生成的文件扩展名为.nib.确保.xib文件的目标是项目的正确viewController,否则仍然会收到错误.
我希望这有帮助.祝好运!
标签:xamarin,xamarin-ios,route-me,ios,c 来源: https://codeday.me/bug/20191120/2047906.html