iOS app crash after UITextField text entry, pop, then push on my navController (NSISObjectiveLinearExpression coefficientForVariable)

試著忘記壹切 提交于 2019-11-29 15:52:16

问题


My iOS app crashes when I:

  • present my "Login" view controller in a navigation controller
  • enter text into a UITextField on it, then try and fail the login
  • pop back to the above view controller
  • push to a different view controller (crashes here)

It doesn't crash if I skip the step where I enter text into the UITextField.

Does anyone have any idea why? Here is the error message I am getting.

[NSISObjectiveLinearExpression coefficientForVariable:]: unrecognized selector sent to instance 0x1cd93850


回答1:


I had this problem too. Using ARC, I would get this crash if I added a UITextField to an otherwise empty xib and, after editing the field, popped its view controller of the navigation controller's stack. The text field had no delegate set and no outlets connected to it. And yet it was crashing!

(If your situation was like mine, you weren't instantiating a NSISObjectiveLinearExpression as mydogisbox suggests. )

After much searching, I found this answer, which suggests calling endEditing: in your viewWillDisappear method. It appeared to fix my crash.

- (void) viewWillDisappear: (BOOL) animated {
    [super viewWillDisappear: animated];
    NSLog( @"In viewWillDisappear" );
    // Force any text fields that might be being edited to end so the text is stored
    [self.view.window endEditing: YES];
}


来源:https://stackoverflow.com/questions/11319144/ios-app-crash-after-uitextfield-text-entry-pop-then-push-on-my-navcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!