MonoTouch.Dialog:如何为EntryElement字符集数的限制集数、何为、字符、MonoTouch

2023-09-03 13:31:16 作者:一见钟情只为你

我找不到如何上限 EntryElement

推荐答案

我preFER继承和事件太:-)试试这个:

I prefer inheritance and events too :-) Try this:

class MyEntryElement : EntryElement {

    public MyEntryElement (string c, string p, string v) : base (c, p, v)
    {
        MaxLength = -1;
    }

    public int MaxLength { get; set; }

    static NSString cellKey = new NSString ("MyEntryElement");      
    protected override NSString CellKey { 
        get { return cellKey; }
    }

    protected override UITextField CreateTextField (RectangleF frame)
    {
        UITextField tf = base.CreateTextField (frame);
        tf.ShouldChangeCharacters += delegate (UITextField textField, NSRange range, string replacementString) {
            if (MaxLength == -1)
                return true;

            return textField.Text.Length + replacementString.Length - range.Length <= MaxLength;
        };
        return tf;
    }
}

也读米格尔的警告(编辑我的职位)位置:MonoTouch.Dialog:对于EntryElement

 
精彩推荐
图片推荐