我在我的应用程序的列表(UITableView)中点击并按住事件:
ViewDidLoad PlayerViewController.m:
UILongPressGestureRecognizer *agendarProg = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(agendarPrograma:)];
agendarProg.minimumPressDuration = 0.5; //segundos
agendarProg.delegate = self;
[self.tableView addGestureRecognizer:agendarProg];
PlayerViewController.m 中的功能 agendarPrograma:
-(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;
}
}
问题:当我使用点击并按住他时,将图像添加到我选择的行上,但也会添加其他图像。我需要它来添加我正在使用点击并按住的位置。在行中添加选择但在列表中随机添加其他图像。
示例:我在“Sorrindo pra vida”中使用点击并按住隐藏图像等于错误,但在“Musicas Marianas”中图像也显示