【发布时间】:2014-11-22 09:34:06
【问题描述】:
我正在尝试将我创建的基本 Objective-C 库绑定到 Xamarin 项目。 .h 文件是:
#import <Foundation/Foundation.h>
@import UIKit;
@interface StarIOFunctions : NSObject {
}
+ (NSMutableData *)GetDataToSendToPrinter:(UIImage *)image;
@end
我尝试使用以下 ApiDefinition 创建绑定:
using System;
using System.Drawing;
using MonoTouch.ObjCRuntime;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace BindingTake2
{
[BaseType (typeof (NSObject))]
interface StarIOFunctions {
[Export ("GetDataToSendToPrinter:image")]
NSMutableData GetDataToSendToPrinter (UIImage image);
}
}
一切都可以编译,但是当我在我的应用程序中运行它时:
UIImage image = UIImage.FromBundle("image1.png");
StarIOFunctions functions = new StarIOFunctions ();
var output = functions.GetDataToSendToPrinter (image);
我的应用程序崩溃并出现以下错误:
Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[StarIOFunctions GetDataToSendToPrinter:image]: unrecognized selector sent to instance 0x7cdb50f0
现在,我认为这与我发送图像有关,而不是指向图像的指针 - 但我完全迷路了,无法弄清楚我到底做错了什么。
【问题讨论】:
标签: c# ios binding xamarin.ios xamarin