I've got an UITableViewand to its UITableViewCells I'm adding a UILongPressGestureRecognizerlike this:
// Setup Event-Handling
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleTableViewCellLongPress:)];
[cell addGestureRecognizer:longPress];
[longPress setDelegate:self];
I would like the cell to blink when the event is fired and I also would like to forbid the standard behaviour (that it turns blue when pressed once).
How can I do this in my handleTableViewCellLongPress-Method?
Thanks!
You could use chaining animations:
- (UITableViewCell *) tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = ...
// remove blue selection
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UILongPressGestureRecognizer *gesture = [[[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handleTableViewCellLongPress:)] autorelease];
[cell addGestureRecognizer:gesture];
return cell;
}
- (void) handleTableViewCellLongPress:(UILongPressGestureRecognizer *)gesture
{
if (gesture.state != UIGestureRecognizerStateBegan)
return;
UITableViewCell *cell = (UITableViewCell *)gesture.view;
[UIView animateWithDuration:0.1 animations:^{
// hide
cell.alpha = 0.0;
} completion:^(BOOL finished) {
// show after hiding
[UIView animateWithDuration:0.1 animations:^{
cell.alpha = 1.0;
} completion:^(BOOL finished) {
}];
}];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With