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
2010-09-25 04:10:14
button is on the view. I add view for tableviewcell. I do this by delegate. but is not userfuly!
raien
2010-09-25 05:09:07
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
2010-09-25 06:43:46
A:
thanks your help! I find the resion is cell's frame! I add the view on cell. so the frame is error!
raien
2010-09-25 07:30:00