Search code examples
iosswiftuitableviewuitextfieldresignfirstresponder

Crash on self.view.endEditing with UITextField in tableviewheader


I experience a quite rare crash when I call self.view.endEditing(true). About 0.3% of my users are affected. I cannot reproduce the crash on my own device. Anyway I would like to fix it.

I have a UITableView that contains a UITextfield in the tableviewheader, that I setup in viewDidLoad(). I have a strong reference to the UITextfield. I also set the delegate to nil in deinit.

When a user taps a row, I call self.view.endEditing() and the app crashes with EXC_BREAKPOINT. The app is in focus when it crashes. The crash happens mostly on iPhone 5, 5c, 5s and 6 (ca. 80%)

I also tried resignFirstResponder with the same issue, also verifying if the textfield is not nil before calling resignFirstResponder did not help.


Solution

  • So thanks to @Vinodh I checked my ViewController in Storyboard. There were still connections to a SearchViewController, that I put out of use. Deleting the connections got me rid of this crash.