Changing the return key to a done key on the iPhone Keyboard (UITextView)
Asked Answered
V

1

5

I'm working on an app with a UITextView. I want to replace the return key on the keyboard with the Done key. I've found code for it but then it's for a UITextField and not a UITextView.

Valenciavalenciennes answered 15/1, 2011 at 22:19 Comment(0)
H
13

You can change the return key with the returnKeyType property

UITextView *textview = [[UITextView alloc] initWithFrame:CGRectMake(0.f, 0.f, 120.f, 40.f)];

textview.returnKeyType = UIReturnKeyDone;
[self.view addSubview:textview];

Regards,
KL94

Higgins answered 15/1, 2011 at 22:34 Comment(5)
I'm getting this one error: expected ',' or ';' before 'initWithFrame' What would I need to do to solve this?Valenciavalenciennes
@Valenciavalenciennes : I forgot some [ ]. I've edited my response. It should work know.Higgins
Hmm it's still a return key in my project. Would you mind uploading the code to mediafire or something when you got time?Valenciavalenciennes
Maybe are you trying to editing some property of an IBOutlet object ? In that case, don't forget to link your UITextView to your delegate... Try my code in a new project, copy it in the viewDidLoad methods of your viewcontroller it'll work.Higgins
Yeah now I get a done key but but it adds another TextView in the upper left corner. (This is the textview I'm getting the done key in. And the textview I created still has the normal return key. And yes I did add the delegate and I link the delegate to the text view and the IBOutlet to the text view. Here is the new project i created with the problem: mediafire.com/?9796p0pu86i1l12 Maybe you know whats wrong.Valenciavalenciennes

© 2022 - 2024 — McMap. All rights reserved.