我有一个UITableView,在它的UITableViewCell%s中添加了一个UILongPressGestureRecognizer,如下所示:
// Setup Event-Handling
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleTableViewCellLongPress:)];
[cell addGestureRecognizer:longPress];
[longPress setDelegate:self];我希望细胞在事件被触发时闪烁,我也希望禁止标准行为(按下一次它就会变成蓝色)。
如何在我的handleTableViewCellLongPress-Method中执行此操作?
谢谢!
发布于 2012-03-09 20:48:26
你可以使用链接动画:
- (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) {
}];
}];
}https://stackoverflow.com/questions/9632815
复制相似问题