tags:

views:

17

answers:

1

Hi,

i´ve created different buttons and initalized them with an array with photos as backgroundImage.

UIButton* myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[myButton setBackgroundImage:[UIImage imageNamed: (NSString*) obj ] forState:UIControlStateNormal];
[myButton addTarget:nil action:@selector(buttonDown: ) forControlEvents:UIControlEventTouchUpInside];

Here´s my buttonDown-method:

-(void) buttonDown:(UIButton*) sender {
NSLog(@"pressed: %@",   sender.currentBackgroundImage  );}

That traced me that: "pressed: < UIImage: 0x6625c40 >"

Now i want to know how can i get that image-name of any clicked button? Would be nice to know.Thanks for your time.

A: 

Since UIImage does not store the name of the image it contains, you can't. You have to store the name elsewhere by yourself in relationship to the Button or image.

regards

ReaperXmac
Thanks, i´ve created a subclass of UIButton and added a new method for that. Thanks for that hint..
geforce