【发布时间】:2013-12-03 16:23:38
【问题描述】:
我正在尝试绑定:https://www.cocoacontrols.com/controls/tsvalidatedtextfield 以用于 Xamarin.iOS。
到目前为止,我已经使用 Objective-C 代码编译了一个静态库,并使用 Objective-Sharpie 生成了 API 定义。
对于其中两个属性,我收到一个错误:
Error CS0246: The type or namespace name `NSRegularExpression' could not be found. Are you missing an assembly reference? (CS0246) (TSValidatedTextField)
Error CS0246: The type or namespace name `ValidationBlock' could not be found. Are you missing an assembly reference? (CS0246) (TSValidatedTextField)
这没有任何意义。据我所知,NSRegularExpression 是我已导入的 Foundation 框架的一部分 (using MonoTouch.Foundation)。
我将如何解决这些错误?如果这两个属性被注释掉,绑定就会编译。
任何帮助将不胜感激。
谢谢大家。
using System;
using System.Drawing;
using MonoTouch.ObjCRuntime;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace TSValidatedTextField
{
public enum ValidationResult {
Passed = 0,
Failed,
ueTooShortToValidate
}
[BaseType (typeof (UITextField))]
public partial interface TSValidatedTextField {
[Export ("regexpPattern")]
string RegexpPattern { get; set; }
[Export ("regexp")]
NSRegularExpression Regexp { get; set; } //ERROR
[Export ("isValid")]
bool IsValid { get; }
[Export ("regexpValidColor")]
UIColor RegexpValidColor { get; set; }
[Export ("regexpInvalidColor")]
UIColor RegexpInvalidColor { get; set; }
[Export ("validatedFieldBlock", ArgumentSemantic.Copy)]
ValidationBlock ValidatedFieldBlock { get; set; } //ERROR
[Export ("validWhenType")]
bool ValidWhenType { [Bind ("isValidWhenType")] get; set; }
[Export ("looksForManyOccurences")]
bool LooksForManyOccurences { [Bind ("isLooksForManyOccurences")] get; set; }
[Export ("occurencesSeparators")]
NSObject [] OccurencesSeparators { get; set; }
[Export ("minimalNumberOfCharactersToStartValidation")]
uint MinimalNumberOfCharactersToStartValidation { get; set; }
}
}
【问题讨论】:
-
NSRegularExpression和ValidationBlock看起来不像是monotouch.dll的一部分 -
不幸的是,是的,我不知道如何将它们包含在内,NSRegularExpression 是 iOS Foundation 框架的成员,但不是 MonoTouch 框架的成员。感谢您的观看。
标签: c# ios objective-c binding xamarin.ios