swift - dismiss keyboard with a uiTextView -


I'm sure it is not difficult, but I key using back / a textview a keyboard, not textfield Even I have tried so far (which works with a textfield.)

Thank you very much for any help!

  // PostTravelQuestion.swift class PostTravelQuestion: UIViewController, UITextViewDelegate {@IBAction func closepostpage (Sender: AnyObject) {dismissViewControllerAnimated (true perfection: zero)} @Iboutlet var postquestion: UITextView! Override funk viewDidload () {super.viewDidLoad () // Setup an additional after loading the view. Postquestion.delegate = self} self addDoneToolBarToKeyboard: self.textView / * func textViewShouldEndEditing (Text View: UITextView) - & gt; Bool {textView.resignFirstResponder () return true} * / / * TouchesBegan function overrides (touches: NSSet, withEvent event: UIEvent) {postquestion.resignFirstResponder () self.view.endEditing (right)} * / override function didReceiveMemoryWarning () { Super.didReceiveMemoryWarning () / any resources that can be reproduced. } Func textViewShouldReturn (textView: UITextView!) - & gt; Boole {self.view.endEditing (true); Back true; }}  

This works for me:

 < Code> Import UIKit Class ViewController: UIViewController, UITextViewDelegate {@IboutletVeror View Text: UITextView! Override function viewDidLoad () {super.viewDidLoad () textView.delegate = self} function TextView (TextView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) - & gt; Bool {if (text == "\ n") {textView.resignFirstResponder () return false} return true}}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -