How to change the return key of UIKeyboard with customized button for iPhone using MonoTouch?

6.7k views Asked by At

I need to add a button to UIKeyboard in the place of Return key and also need to raise events for that customized button for iPhone using MonoTouch.

2

There are 2 answers

7
jbat100 On BEST ANSWER

Take a look at the UITextInputTraits protocol. It defines a returnKeyType (UIReturnKeyType) which can be

typedef enum {
   UIReturnKeyDefault,
   UIReturnKeyGo,
   UIReturnKeyGoogle,
   UIReturnKeyJoin,
   UIReturnKeyNext,
   UIReturnKeyRoute,
   UIReturnKeySearch,
   UIReturnKeySend,
   UIReturnKeyYahoo,
   UIReturnKeyDone,
   UIReturnKeyEmergencyCall,
} UIReturnKeyType;

The UITextField and UITextView classes support this protocol. I don't think you can customize it further unless you do some very hacky stuff.

If you have a UITextField then you can implement

- (BOOL)textFieldShouldReturn:(UITextField *)textField

and if you have a UITextView you can implement

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text

both delegate methods, to determine the behaviour on return.

1
Adam Roberts On

You could add a UIButton on the superview in the same postion of the keyboard button.