views:

50

answers:

3

I want to add view for tableviewcell. click the button on the view. however. why it responsed is didselected event. not click event. please help me! thanks very much!

A: 

When you add the button to the cell, you also need to set its target and action.

So, this is how you would add a button to a cell's accessory view and set it to run the "myEvent" event when the user taps the button:

UITableViewCell *cell;
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton addTarget:self 
             action:@selector(myEvent) 
   forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = myButton;

Hope that helps... It was somewhat tricky trying to decode your question!

h4xxr
button is on the view. I add view for tableviewcell. I do this by delegate. but is not userfuly!
raien
A: 

Try myButton.userInteractionEnabled = YES; and the set the same for the view you add. Honestly, it isn't clear for me what are you talking about

NR4TR
A: 

thanks your help! I find the resion is cell's frame! I add the view on cell. so the frame is error!

raien