How to perform UIButton action before loading next view

淺唱寂寞╮ 提交于 2019-12-13 04:05:43

问题


I have a view where a user enters 3 sting fields. On the button press the fields are stored in an array. The button also changes the view.

The problem im having is when I get the strings from the array in the other view. The values that are being returned are the pervious values that have been entered.

I have added some lines to log what is going in and what is come out of the arrays. From the log I can see that the array is being called before it is set.

How to I get the button to run its action before it changes the view?

Here is my log:

2012-09-27 14:56:49.530 BeerDivider[1585:907] GetArray:(null)
2012-09-27 14:56:49.543 BeerDivider[1585:907] SetArray:(
    3,
    will,
    Harry
)

EDIT: Here is my code. http://pastebin.com/BX5gqp17


回答1:


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"yourSegue"]) {
       //do what you need
    }
}


来源:https://stackoverflow.com/questions/12623060/how-to-perform-uibutton-action-before-loading-next-view

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