我在我们的项目中使用单声道绑定(bind)包含了“Cocoa Controls”中的一些控件,它们都工作正常,除了有一个我无法工作,我希望有人能发现一个明显的错误。
这是 Objective-C header
typedef enum {
kWTShort = 1,
kWTLong = 5
} WToastLength;
@interface WToast : UIView
+ (void)showWithText:(NSString *)text;
+ (void)showWithImage:(UIImage *)image;
+ (void)showWithText:(NSString *)text length:(WToastLength)length textColor:(UIColor *) textColor backgroundColor:(UIColor *) backGroundColor;
+ (void)showWithImage:(UIImage *)image length:(WToastLength)length;
@end
这是 Mono ApiDefinition
[BaseType (typeof(UIView))]
interface WToast
{
[Export("showWithText:")]
void ShowText(String text);
[Export("showWithText:length:textColor:backgroundColor:")]
void ShowText(string text,ToastLenght lenght,UIColor textColor,UIColor backgroundColor);
}
注意我没有包含枚举 ToastLength
对象以任何方式实例化,但当我调用 ShowText 时,程序找不到选择器 [WToast showWithText:]
希望有人能帮忙
问候克里斯蒂安·斯托尔·安德森
最佳答案
我想我只需要暂时离开代码一段时间。
答案是我有点厚
您会注意到 objective-c 函数是
+ (void)showWithText:(NSString *)text;
不是
- (void)showWithText:(NSString *)text;
Mono 定义应该是
[Static,Export("showWithText:")]
void ShowText(String text);
不是
[Export("showWithText:")]
void ShowText(String text);
谢谢大家
关于objective-c - Monotouch Objective-C 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13081288/