iOS do the button's action before prepareSegue

自作多情 提交于 2019-12-08 05:52:29

问题


Basically, I have a button that when you press it, it runs its action methond (changes a field in my Data class) and segues into another view which displays the field. After some debugging I realized that prepareSegue, and perhaps other related methods run before my button's action, and thus display the old field value instead of the new. Is there anyway around this. I was thinking maybe instead of segueing on the button press, I would create a segue to my first scene and segue to it at the end of my buttons action method, but am not sure how to set the destination of a segue made programmatically. Or is there a better way to update the field before segueing? Thanks in advance.


回答1:


If the segue is happening automatically you can do the work (field update) inside prepareForSegue:. The segue you're given in that method can provide a reference to the new controller and the sender parameter should be your button.



来源:https://stackoverflow.com/questions/11689985/ios-do-the-buttons-action-before-preparesegue

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