Ho un grosso problema. Sto cercando di creare un pulsante preferito su ogni UITableViewCell
in un UITableView
. Funziona molto bene, e al momento ho un'azione e un selettore eseguito quando premuto.UITableViewCell Accessorio personalizzato - ottieni la fila di accessori
accessory = [UIButton buttonWithType:UIButtonTypeCustom];
[accessory setImage:[UIImage imageNamed:@"star.png"] forState:UIControlStateNormal];
accessory.frame = CGRectMake(0, 0, 15, 15);
accessory.userInteractionEnabled = YES;
[accessory addTarget:self action:@selector(didTapStar) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = accessory;
E selettore:
- (void) didTapStar {
UITableViewCell *newCell = [tableView cellForRowAtIndexPath:/* indexPath? */];
accessory = [UIButton buttonWithType:UIButtonTypeCustom];
[accessory setImage:[UIImage imageNamed:@"stared.png"] forState:UIControlStateNormal];
accessory.frame = CGRectMake(0, 0, 26, 26);
accessory.userInteractionEnabled = YES;
[accessory addTarget:self action:@selector(didTapStar) forControlEvents:UIControlEventTouchDown];
newCell.accessoryView = accessory;
}
Ora, ecco il problema: voglio sapere cosa riga l'accessorio che è stato premuto appartiene. Come posso fare questo?
Grazie :)
Anche io lo uso. – ZYiOS