Tengo un botón y una Tabla. Ahora quiero hacer clic de tal manera que cada vez que seleccione una fila en tableview
y presione el botón, ese evento de pulsación de botón en particular ocurra. Para ello, en primer lugar me he darle etiqueta para cada fila es decirHacer clic en Evento en UITableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *LabelCellIdentifier = @"cell";
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:LabelCellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:LabelCellIdentifier];
}
if (indexPath.row <= [_arrayMp3Link count]) {
cell.textLabel.text = [_arrayMp3Link objectAtIndex:indexPath.row];
}
// now tag each row
NSInteger count = 1;
for (NSInteger i = 0; i < indexPath.section; i++) {
count += [[tableView dataSource] tableView:tableView numberOfRowsInSection:i];
}
count += indexPath.row;
// dequeue, create and configure...
cell.tag = count;
return cell;
}
y ahora en poner evento en el botón cuando selecciono la fila y pulse el botón de mi. Pero no obteniendo las cosas correctas.
(IBAction)doDownload:(id)sender {
// to select first row
if(cell.tag==1)
{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://www.google.com"]];
}
Puede obtener la fila de la IBAction. Mira mi respuesta aquí: http://stackoverflow.com/a/12594183/1144632 – danielbeard