Hi, my app has eight views, one view has seven buttons each of these buttons opens another view when clicked. these views are all identical apart from the code to setup the array and the only different thing about that is the names for the images. The names for the images on the first view would be Grp1-1, Grp1-2, the names for the second view would be Grp2-1 and so on.
Hi, my app has eight views, one view has seven buttons each of these buttons opens another view when clicked. these views are all identical apart from the code to setup the array and the only different thing about that is the names for the images. The names for the images on the first view would be Grp1-1, Grp1-2, the names for the second view would be Grp2-1 and so on.
So my question is if i just had one view, how could i know which images to show depending on which button was pressed?
Thanks
Mick
Tag the buttons, or set some kind of attribute/property. Then, use an (id)sender argument in the buttonPressed method, and check for the value of that tag or property.
- (IBAction)buttonPressed: (id)sender {
if (sender.number == 0)
[self loadView:view0];
else if (sender.number == 1)
[self loadView:view1];
...
}
You could also build an array of views, then enumerate through them...
Hi, thanks for the reply, what i ultimately want is to get rid of six of the seven similar views. The remaining view would load slightly different array depending on the button pressed so the code to decide this would be on the view to be opened so would this view be able to detect which button was pressed on a different view?