我正在尝试为Good Dynamics创建绑定,以便可以在Xamarin中使用它。我终于到了要构建它的地步,但是在尝试初始化Good Dynamics时会发生以下错误;
MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsisenter code heretencyException Reason: AppDelegate does not implement UIApplicationDelegate. Check that the class is correct and it conforms to this protocol.
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend_IntPtr (intptr,intptr,intptr)
at GDBinding.GDiOS.InitializeWithClassConformingToUIApplicationDelegate (MonoTouch.ObjCRuntime.Class applicationDelegate) [0x00000] in <filename unknown>:0
at GDTest.Application.Main (System.String[] args) [0x00006] in /Users/gareth/GDTest/GDTest/Main.cs:20
Main.cs的第20行是
GDiOS.InitializeWithClassConformingToUIApplicationDelegate(new MonoTouch.ObjCRuntime.Class(typeof(AppDelegate)));
我尝试让AppDelegate扩展UIApplicationDelegate,还扩展GDiOSDelegate,后者具有UIApplicationDelegate的基本类型,并具有相同的结果。
namespace GDBinding
{
[BaseType (typeof (NSObject), Delegates = new string[] {"WeakDelegate"}, Events = new Type[] {typeof(GDiOSDelegate)})]
interface GDiOS {
[Export ("delegate", ArgumentSemantic.Assign)]
NSObject WeakDelegate { get; set; }
[Wrap("WeakDelegate")]
[NullAllowed]
GDiOSDelegate Delegate { get; set; }
//+ (void)initializeWithClassNameConformingToUIApplicationDelegate:(NSString*)applicationDelegate;
[Static, Export ("initializeWithClassNameConformingToUIApplicationDelegate:")]
void InitializeWithClassNameConformingToUIApplicationDelegate (string applicationDelegate);
//+ (void)initialiseWithClassConformingToUIApplicationDelegate:(Class)applicationDelegate;
[Static, Export ("initializeWithClassConformingToUIApplicationDelegate:")]
void InitializeWithClassConformingToUIApplicationDelegate (Class applicationDelegate);
//+ (BOOL)isInitialized;
[Static, Export ("isInitialized")]
bool IsInitialized();
//+ (GDiOS*)sharedInstance;
[Static, Export ("sharedInstance")]
GDiOS SharedInstance();
//- (UIWindow*)getWindow;
[Export ("getWindow")]
UIWindow GetWindow();
}
[BaseType(typeof(UIApplicationDelegate))]
interface GDiOSDelegate {
[Abstract, Export("handleEvent:")]
void HandleEvent(GDAppEvent anEvent);
}
[BaseType(typeof(NSObject))]
interface GDAppEvent {
[Export("message")]
string Message { get; set; }
[Export("code")]
GDAppResultCode Code { get; set; }
[Export("type")]
GDAppEventType EventType { get; set; }
}
}
代码位于https://github.com/garethrhughes/GDTest
我认为问题可能与将monotouch AppDelegate传递到本机库有关。
有任何想法吗?
谢谢
最佳答案
我知道这是一个旧线程,但是我和一位同事刚刚使用新版本的GOOD SDK(v1.8.x)进行了此过程,并使其能够正常工作。我们发布了有关here的文章,其中还包含一个示例项目的链接。
关于ios - Xamarin AppDelegate初始化良好的Dynamics时未实现UIApplicationDelegate,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12972272/