views:

63

answers:

2

I'm using DialogViewController from MonoTouch.Dialogs. I'd like to be able to dismiss the keyboard by clicking on the background of the dialog.

I usually employ the technique of filling the view with a large custom button and placing it behind all the other elements. However, I can't make this work in the DialogViewController. I did this in LoadView and it just froze all the other controls.

Is there a relatively straightforward way of achieving what I want?

A: 
[mytextField resignFirstResponder];
Matt Williamson
+3  A: 

In view controller:

public override void TouchesBegan (NSSet touches, UIEvent evt)
    {
        base.TouchesBegan (touches, evt);

        myField.ResignFirstResponder();
    }

Edit: From what I've read, you can use the TouchesBegan event for the cell subview instead of the table itself. I'm not positive that works. Good luck :)

ifwdev
+1 for actually having it in .net :)
Matt Williamson
+1 as it's a neat approach to the more general problem. However, it doesn't solve my problem with MonoTouch.Dialog. This is descended from UITableViewController, which doesn't seem to receive the TouchesBegan event.
dommer