I have the custom UITableViewCell and this code to create the accessory
UIImage *indicatorImage = [UIImage imageNamed:@"Map.png"];
UIButton *button = [[UIButton alloc] init];
[button setImage:indicatorImage forState:UIControlStateNormal];
[button setFrame:CGRectMake(0, 0, 64, 64)];
cell.accessoryView = button;
and i have this two methods:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//[self performSegueWithIdentifier:@"goToDetail" sender:self];
NSLog(@"row");
}
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{
//[self performSegueWithIdentifier:@"goToMap" sender:self];
NSLog(@"accessory");
}
I would like to capture two different events: 1 for the row and one for the accessory, with the two methods that I put above I can only get the event for the row. How do I get the accessory?
help please
in every row i add this button that i set like an accessory:
UIButton *button = [[UIButton alloc] init];
[button setImage:indicatorImage forState:UIControlStateNormal];
[button setFrame:CGRectMake(0, 0, 64, 64)];
[button addTarget:self action:@selector(methodTouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
button.tag = indexPath.row;
cell.accessoryView = button;
now i create this metod
-(void)methodTouchUpInside:(id)sender
every time we tap on a button in a row , he call this meted. to select the button that call him we can use button.tag!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.