textView not working correctly

I read data from a file and append it to a textView. I can then bring up the keyboard to edit the data. I save the data when exiting. If I used [self.myTextView resignFirstResponder] to remove the keybard and then come back to the textView I can no longer access the textView field. If I comment out the [self.myTextView resignFirstResponder] the keyboard never goes away, but the data is properly written to the textView field.


Any ideas why the resignFirstResponder is causing an issue?

Replies

Could you show the complete code ? When do you call resign ? When you type return ? When tapping a Done button ?


What do you mean "I can no longer access the textView field."

Do you mean the keyboard will not show anymore ?


Is it in simulator or on device ?

I realize how confusing my question sounds. I need to rethink this and find what code I can present.

I tested this (Swift) and works OK:


class ThirdViewController: UIViewController, UITextViewDelegate {

    @IBOutlet weak var textView: UITextView!
   
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
   
    func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
       
        if text == "\n" {
            textView.resignFirstResponder()
        }
        return text != "\n"
    }

}

@imsmooth Did you test with this simple code ?