Get Updates By E-mail 

Article Written By:
Johann Dowa

Custom Behavior On Return For A UITextView

  •  
  •  
  •  
  •  
  •  

The default behavior for a UITextField on pressing the return key is to execute the textFieldShouldReturn: method of the UITextFieldDelegate.

What if we wanted to create similar behavior with a a UITextView which does not have an equivalent method and by default just creates a new line?

Nick Dalton has come up with a snippet of code that uses the:

textView:shouldChangeTextInRange:replacementText:

method of the UITextViewDelegate to do just that.

You can check the article out here: Handling The Return Key In A UITextView

It’s a very handy bit of code to have as there are many situations where you may want to implement custom behavior when the return key is pressed in a UITextView.

Thanks Nick.

Please post any comments below, thanks.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments