简体   繁体   English

导航控制器中的“后退”按钮上的应用程序崩溃

[英]application crashing on clicking back button in navigation controller

I have a table in my view controller (navigation controller). 我的视图控制器(导航控制器)中有一个表。 It contains 5 rows. 它包含5行。 When I click on one 3rd row, a new view controller is pushed onto the stack. 当我单击第三行时,新的视图控制器被推入堆栈。 This new controller also contains a table view and the cells in that table view contains text fields (added using cell.contentView addSubView:). 此新控制器还包含一个表格视图,该表格视图中的单元格包含文本字段(使用cell.contentView addSubView:添加)。 On clicking one of the text field, a picker is shown (using textField.inputView) instead of keyboard. 单击文本字段之一后,将显示一个选择器(使用textField.inputView)而不是键盘。 Now, without selecting any item in picker, I click on back button, then my view gets popped. 现在,在选择器中没有选择任何项目的情况下,我单击“后退”按钮,然后弹出我的视图。 But after a while (when I am on my root view controller), the app gets crashed. 但是过了一会儿(当我在根视图控制器上时),该应用程序崩溃了。

But If I click on a text field (which is showing keyboard), and then press back button; 但是如果我单击一个文本字段(显示键盘),然后按返回按钮; no crash occurs. 没有崩溃发生。 So, what might be the problem?? 那么,可能是什么问题呢?

Looks like you have some bug in your logic. 看起来您的逻辑中有一些错误。 Try to Build and debug and see in debugger(run-debugger) stack of calling functions. 尝试构建和调试并在debugger(run-debugger)调用函数堆栈中查看。

If you use a pointer without initializing it to nil or any other object, you are propably going to end up accessing memory which isn't yours. 如果使用指针时未将其初始化为nil或任何其他对象,则很可能最终将访问不是您自己的内存。 this type of code will also give an EXC_BAD_ACCESS error , that means you are truing to use memory which is not yours. 这种类型的代码还会给出EXC_BAD_ACCESS错误,这意味着您正在努力使用不是您自己的内存。 so first trace your code using break points line by line. 因此,首先使用断点逐行跟踪代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM