Skip to content

Instantly share code, notes, and snippets.

@martinbowling
Created March 26, 2010 23:49
Show Gist options
  • Save martinbowling/345550 to your computer and use it in GitHub Desktop.
Save martinbowling/345550 to your computer and use it in GitHub Desktop.
entry.KeyboardType = KeyboardType;
if (KeyboardType == UIKeyboardType.NumberPad)
{
NSNotificationCenter.DefaultCenter.AddObserver (
"UIKeyboardDidShowNotification", (notification) => {
UIButton doneButton = new UIButton(new RectangleF(0, 163, 106, 53)); //{ButtonType = UIButtonType.Custom};
//doneButton.SetTitle("Done", UIControlState.Normal);
doneButton.SetImage(UIImage.FromFile("DoneUp.png"), UIControlState.Normal);
doneButton.SetImage(UIImage.FromFile("DoneDown.png"), UIControlState.Highlighted);
doneButton.AdjustsImageWhenHighlighted = false;
UIWindow window = UIApplication.SharedApplication.Windows[1];
IntPtr sel = Selector.GetHandle ("description");
foreach (var v in window.Subviews)
{
//NSString desc = Runtime.GetNSObject (Messaging.IntPtr_objc_msgSend (v.Handle, Selector.GetHandle ("description")));
if (KeyboardHandle == System.IntPtr.Zero)
{
NSString desc = (NSString) Runtime.GetNSObject (Messaging.IntPtr_objc_msgSend (v.Handle, sel));
Console.WriteLine(desc.ToString());
if (desc.ToString ().StartsWith ("<UIKeyboard")) {
//v.Tag = 313377269;
KeyboardHandle = v.Handle;
v.AddSubview(doneButton);
break;
}
}
else if (v.Handle == KeyboardHandle)
{
KeyboardHandle = v.Handle;
v.AddSubview(doneButton);
break;
}
}
doneButton.TouchUpInside += delegate {
entry.ResignFirstResponder();
};
Console.WriteLine ("Keyboard went up");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment