viewDidLoad called before an IBAction?

佐手、 提交于 2019-12-06 15:13:30

问题


in my Xcode project I have a button, that does two things.

First: call an IBAction Second: go to another view (segue)

In the action linked to the button I set a variable to YES (global var), but in the viewDidLoad method in the linked view, its still NO. Its YES in viewDidAppear though. I wonder why the action is not called first. Can I change that? I'd prefer to use the viewDidLoad method, since it seems to load quicker.


回答1:


You can use the prepareForSegue method to pass whatever data to the destination view before the segue assigned to the button is performed. This data will be available in the destination view viewDidLoad



来源:https://stackoverflow.com/questions/22212618/viewdidload-called-before-an-ibaction

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