I am trying to bind: https://www.cocoacontrols.com/controls/tsvalidatedtextfield for use with Xamarin.iOS.
So far, I have compiled a static library with the Objective-C code and I have generated API Definitions with Objective-Sharpie.
For two of the properties, I am getting an error:
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)
It doesn't make any sense. As far as I know, NSRegularExpression is part of the Foundation framework, which I have imported ( using MonoTouch.Foundation
).
How would I go about fixing these errors? The binding compiles if these two properties are commented out.
Any help would be greatly appreciated.
Thanks guys.
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
and ValidationBlock
aren't part of Xamarin.iOS
.
That doesn't mean you're stuck there. just like you're binding TSValidatedTextField
, you can bind them yourself.
Once it's done, it's probably better to mark the NSRegularExpression Regexp { get; set; }
NSRegularExpression Regexp { get; set; }
NSRegularExpression Regexp { get; set; }
with [Internal]
and write some custom code to expose a .NET System.Text.RegularExpressions.Regex
, more natural to use in C#.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.