Possible Duplicate:
Subclassing and overriding UITextField in Monotouch
So, I am using MonoTouch and basically trying to convert a lot of Obj-C code to MonoTouch. The problem is that MonoTouch isn't well documented for a lot of things (or at least I cannot find it).
On my form (yeah, I call it a form still) I have a UITextField with Placeholder text. It works beautifully until I specified the Custom Class which is CustomUITextField. (see below).
The problem is that it my breakpoints are being hit when I load the screen that it's on. But, nothing does anything. No placeholder is even shown anymore even when I call base.DrawPlaceholder(rect); from the override method. I would expect that by calling base.DrawPlaceholder(rect); that I would at least get the default functionality of showing the placeholder text (this works without using my custom class - tested).
If I continue to use this custom class but remove the override DrawPlaceholder method from my implementation, then the standard placeholder text displays fine. How in the world is that any different than overriding DrawPlaceholder and then calling base.DrawPlaceholder(rect);. It's the same thing.
Does anyone have any idea what I am doing wrong here? I am going crazy...
using System;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using System.Drawing;
namespace MyApp
{
[Register("CustomUITextField")]
public class CustomUITextField:UITextField
{
public CustomUITextField () :base()
{
}
public CustomUITextField (IntPtr handle) :base()
{
this.BackgroundColor=UIColor.Black;
}
public override void DrawPlaceholder (RectangleF rect)
{
this.BackgroundColor=UIColor.Black;
base.DrawPlaceholder(rect);
//UIColor col = new UIColor(0,0,255,0);
//col.SetFill();
//this.DrawString ("Title",rect, this.Font);
}
public override void DidChange (NSKeyValueChange changeKind, NSIndexSet indexes, NSString forKey)
{
base.DidChange (changeKind, indexes, forKey);
}
public override void DidChangeValue (string forKey)
{
base.DidChangeValue (forKey);
this.Text="";
}
}
}