У меня есть табличное представление, и к ячейкам в нем добавлен UILongPressGestureRecognizer. Проблема в том, что как только ячейка коснулась, она подсвечивается, но как только мой длинный жест начинается (удерживая кнопку), подсветка исчезает. Жест работает, и он все еще удерживается, но немного сбивает с толку пользователя, потому что они не знают, удерживается ли он до сих пор. Как сделать так, чтобы камера оставалась выделенной на протяжении всего удержания.
некоторый код:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//add long press gesture for the audio AB (eventually VC and TP as well) list
//so that users can hold the cell and after 5 seconds have the dialpad for editing that entry
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleLongPress:)];
longPress.minimumPressDuration = 1;
[cell addGestureRecognizer:longPress];
}
cell.textLabel.text = [self.tableArray objectAtIndex:indexPath.row];
return cell;
}
- (void)handleLongPress:(UILongPressGestureRecognizer*)sender
{
//used to get indexPath of cell pressed
UITableViewCell *cell = (UITableViewCell *)[sender view];
//get the indexPath of cell pressed
NSIndexPath *indexPath = [self.myTableView indexPathForCell:cell];
//use the index press to figure out the proper join to hold
self.sharedJoinNumber = indexPath.row+286 ;
}