(Continued from this thread)
Suppose that I have the following view created:
The ‘View’ button is supposed to push a new ViewController which will show all photos by either Josh or Al, depending on which button is pressed.
My question is:
In the ViewController code, how do I determine which ‘View’ button is pushed (top or bottom)?
This is the code that I have:
- (IBAction) viewImageList {
PhotoListViewController* photoListViewController = [[PhotoListViewController alloc]
initWithNibName:@"PhotoListViewController"
bundle:[NSBundle mainBundle]];
// here, I want to dynamically pass in the name (Josh or Al) based on which 'View' button is pressed
photoListViewController.ownerName = @"someName";
[[self navigationController] pushViewController:photoListViewController animated:YES];
[photoListViewController release];
}
Or if anyone have a different approach, I’d like to hear it 🙂
Your IBAction should receive a pointer to the sender of the event:
(IBAction)viewImageList:(id)senderYou can either inspect the
tagproperty of the sender, or keep an array of the buttons and compare the identity of the sender to the identities of the buttons in the array to see where the click originated.