按下后退按钮时销毁视图
我的导航控制器是这样组织的:
FirstViewController -> SecondViewController ->; 第一个中的ThirdViewController
我在网络上进行搜索并将结果显示在 UITableView 中 当我选择一个单元格时,我会推到第二个单元格,在其中根据之前按下的键进行另一次搜索,并显示一些信息和“更多信息”按钮 当我按下按钮时,我推到第三个视图,这工作正常...
问题是当我按两次后退按钮进行另一次搜索时:当我到达第三个视图时,我每次都会显示有关第一个视图的信息搜索!
这是因为我在loadView中显示信息,并且这只是第一次调用,对吧?
我该怎么办?
谢谢你!
My navigation controller is organized this way:
FirstViewController -> SecondViewController -> ThirdViewController
in the First I do a search on the web and I display the result in a UITableView
when I select a cell I push to the Second where I do another search based on key previously pressed and I display some information and a button for "more info"
when I press the button I push to the Third view and this works fine...
The problem is when I press two times the back button for doing another search: when I arrive at the third view I display every time the informations about the first search!
this is because I do the display of information in loadView and this is called only the first time, right?
How should I do?
thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,
viewDidShow
是在从 NIB 文件加载并创建视图之后调用的。。这意味着您应该只使用该方法来执行初始化操作。添加一个新方法并在每次获得新结果时调用它:
您可以从第一个或第二个视图控制器调用它,如下所示:
希望有帮助。请点击左侧“√”标记为最佳答案!谢谢。
Indeed
viewDidShow
is called after the view has been loaded and created from the NIB file. This means you should only use that method to do initialization stuff.Add a new method and call it everytime you have new results:
You'd call it from the first or second view controller like this:
Hope that helps. Please mark the best answer by clicking the "√" on the left! Thanks.
你可以在viewdidunload中清理ThirdViewController。
You can clean up the the ThirdViewController in viewdidunload.