Assuming your view controller with the buttons is in a navigation controller - presumably at the root...
What you would do is, add a target to each of your buttons, in code this can be done with the method addTarget:action:forControlEvents:
of your UIButton
For example:
[myBtn addTarget:self action:@selector(tappedButton:) forControlEvents:UIControlEventTouchUpInside];
The method tappedButton will be messaged with the button that was tapped:
- (void)tappedButton:(UIButton*)sender{
// exploit the button
}
Inside this method you can get the title of the button - myBtn.titleLabel.text
You can then create a new view controller (let's keep things simple and say you have your own UIViewController
subclass called MySimpleViewController
.
In this class you have a cameFrom
property which you can set the button's title on, and in viewDidLoad
of MySimpleViewController
, you would get the property value of cameFrom
, this could be the method implementation.
- (void)tappedButton:(UIButton*)sender{
MySimpleViewController *detail = [[MySimpleViewController alloc] init];
detail.cameFrom = sender.titleLabel.text;
[self.navigationController pushViewController:detail
animated:YES];
[detail release];
}
So over in your MySimpleViewController's
viewDidLoad
, you create a UILabel
, give the text property the value of self.cameFrom
and add it to the view with addSubview: