tags:

views:

48

answers:

0

Hi, i have the code:

UIButton *button = [[UIButton buttonWithType:UIButtonTypeCustom] initWithFrame:CGRectMake(25, 0, 35, 35)]; [button setTitleColor:[UIColor clearColor] forState:UIControlStateNormal]; [button setBackgroundColor:[UIColor clearColor]]; [view addSubview:button];

Now i add a action

[button addTarget:elem1 action:@selector(openLink) forControlEvents:UIControlEventTouchUpInside];

Now i want change the target with other element (dinamically)

[button addTarget:elem2 action:@selector(openLink) forControlEvents:UIControlEventTouchUpInside];

but when the button is clicked, fires [elem1 openLink] and [elem2 openLink], i dont have the reference to elem1 so i can't [button removeTarget:elem1 action:@selector(openLink) forControlEvents:UIControlEventTouchUpInside];

so how fire only [elem2 openLink]??

Or other way (maybe) is send param

[button addTarget:genericElem action:@selector(openLink:link??) forControlEvents:UIControlEventTouchUpInside]; but were send the "link" content?