I have a tap and hold the event in the list (UITableView) of my application:
ViewDidLoad PlayerViewController.m:
UILongPressGestureRecognizer *agendarProg = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(agendarPrograma:)];
agendarProg.minimumPressDuration = 0.5; //segundos
agendarProg.delegate = self;
[self.tableView addGestureRecognizer:agendarProg];
function agendarPrograma in PlayerViewController.m:
-(void)agendarPrograma:(UILongPressGestureRecognizer *)gestureRecognizer {
CGPoint ponto = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:ponto];
cell = [self.tableView cellForRowAtIndexPath:indexPath];
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
if (cell.imageAgendamento.hidden == true) {
cell.imageAgendamento.hidden = false;
NSString *horaPrograma = [ NSString stringWithFormat:@"%@",[[results objectAtIndex:indexPath.row] objectForKey:@"hora" ]];
[self addNotification:horaPrograma];
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"Agendamento" message:@"Programa agendado" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[alert1 show];
[self performSelector:@selector(dismiss:) withObject:alert1 afterDelay:1.5];
} else {
cell.imageAgendamento.hidden = true;
[self deleteNotification];
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"Agendamento" message:@"Agendamento cancelado" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[alert1 show];
[self performSelector:@selector(dismiss:) withObject:alert1 afterDelay:1.5];
}
} else {
return;
}
}
PROBLEM: when I use tap and hold him add the image on the line I chose but also add in others. I need it to add just where I'm using tap and hold. add in row choose but add other imagem in list random.
EXAMPLE: I used tap and hold in "Sorrindo pra vida" hidden image equal a false, but in "Musicas Marianas" the image show too