viewDidLoad called before an IBAction?

2019-04-17 23:03发布

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条回答
不美不萌又怎样
2楼-- · 2019-04-17 23:50

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

查看更多
登录 后发表回答