问题
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