4

我想将Aviary SDK Objective-C 库集成到 Monotouch 项目中。我为此使用“Monotouch Binding Project”模板。我已经构建了 DLL(感谢聪明人!)该项目在模拟器上编译并运行。

但是我无法显示主 Aviary 视图和以下代码

            this.afPhotoEditor = new AFPhotoEditorController(UIImage.FromFile("Images/site.jpg"));
            AFDelegate afDelegate = new AFDelegate(this);
            this.afPhotoEditor.Delegate = afDelegate;
            this.PresentModalViewController(this.afPhotoEditor, true);

返回错误:

Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: Cannot create an NSPersistentStoreCoordinator with a nil model
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_bool (intptr,intptr,intptr,bool)
  at MonoTouch.UIKit.UIViewController.PresentModalViewController (MonoTouch.UIKit.UIViewController modalViewController, Boolean animated) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:261 
  at TestAviary.FirstViewController.<ViewDidLoad>m__0 (System.Object , System.EventArgs ) [0x00028] in /Users/mahmood1/Projects/AviaryBinding/TestAviary/FirstViewController.cs:61 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at TestAviary.Application.Main (System.String[] args) [0x00000] in /Users/mahmood1/Projects/AviaryBinding/TestAviary/Main.cs:17 
[ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: Cannot create an NSPersistentStoreCoordinator with a nil model
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_bool (intptr,intptr,intptr,bool)
  at MonoTouch.UIKit.UIViewController.PresentModalViewController (MonoTouch.UIKit.UIViewController modalViewController, Boolean animated) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:261 
  at TestAviary.FirstViewController.<ViewDidLoad>m__0 (System.Object , System.EventArgs ) [0x00028] in /Users/mahmood1/Projects/AviaryBinding/TestAviary/FirstViewController.cs:61 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at TestAviary.Application.Main (System.String[] args) [0x00000] in /Users/mahmood1/Projects/AviaryBinding/TestAviary/Main.cs:17 

这个错误(Cannot create an NSPersistentStoreCoordinator with a nil model)似乎与 Aviary SDK 需要添加的资源包相关联。

来自Aviary iOS 设置指南

4. Copy resources

Make sure AviarySDKResources.bundle is included in your target's "Copy Bundle Resources" build phase.

所以我通过 MonoDevelop 中的“添加现有文件夹..”菜单项添加了这个包。

来源放在这里>>> http://www.axifile.com/en/71EC96914A

它包括2个项目:

  • AviaryBinding(MonoTouch 绑定项目)
  • 测试鸟舍

谢谢!

4

1 回答 1

0

根据Jonathan.Peppers 的评论:

Build Action使用of将大多数这样的文件添加到您的项目Content中将解决该问题。

于 2012-06-15T04:59:21.820 回答