IOS - How to determine which button is starting a session and how to display its content based on the button
My problem is that I have a view with different buttons inside: all buttons are connected to the same segment (this is for some specific reason, I know it would be easier to do different sessions, but that I need the right to present).
How can I determine which button launched my new session and how can I change the data on new sites in this solution? (for example my new segue has in image view that should load a different image for each button)
+3
source to share
1 answer
in the method -prepareForSegue:sender:
, in the sender parameter, you refer to the control that triggers the segue, for example:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"yourIdentifier"]) {
UIButton *senderButton = (UIButton *)sender;
// do what ever you need with the button and segue
}
}
+3
source to share