0
私は自分のテーブルビューを持ち、そのセル内にはUILongPressGestureRecognizerが追加されています。問題は、タッチしたセルが強調表示されると強調表示されますが、長いジェスチャが開始されると(ボタンを押し続けると)強調表示が消えてしまうことです。ジェスチャーはまだ動作していますが、それはまだ保持されているかどうかは分かりませんので、ユーザには少し混乱します。保留中にどのようにセルを強調表示させることができますか?セル内でholdgestureを持つtablview un-highlighting
いくつかのコード:私はこの問題は右しかし今のホールドが次のセルがするニーズをクリックキャンセルされた場合- (void)handleLongPress:(UILongPressGestureRecognizer*)sender
後
//highlight the apprioriate cell
[self.myTableView selectRowAtIndexPath:indexPath animated:FALSE scrollPosition:UITableViewScrollPositionNone];
を用いて固定取得した
- (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 ;
}
私は[cell setHighlighted:YES animated:YES]を試してみることをお勧めします。 –