我已经在视图中添加了一个轻击手势,起初它似乎有效,但在动画完成后,手势完全被忽略,直到视图返回原位。
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[self.cellView addGestureRecognizer:tap];
[tap release];
在这里,我将视图设置为右侧的动画
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^
{
[cellView setFrame:CGRectMake(cellViewX, cellView.frame.origin.y, cellView.frame.size.width, cellView.frame.size.height)];
[editView setFrame:CGRectMake(editViewX, editView.frame.origin.y, cellView.frame.size.width, cellView.frame.size.height)];
}
completion:^(BOOL finished)
{
NSLog(@"Animation complete");
}];
触发完成处理程序,但现在完全忽略了点按手势。
答案 0 :(得分:1)
好的,事实证明我只是做了一个愚蠢的复制/粘贴错误,我在为动画设置框架时意外地使用了错误的值
[cellView setFrame:CGRectMake(cellViewX, cellView.frame.origin.y, cellView.frame.size.width, cellView.frame.size.height)];
[editView setFrame:CGRectMake(editViewX, cellView.frame.origin.y, cellView.frame.size.width, cellView.frame.size.height)];
必须
[cellView setFrame:CGRectMake(cellViewX, cellView.frame.origin.y, cellView.frame.size.width, cellView.frame.size.height)];
[editView setFrame:CGRectMake(editViewX, editView.frame.origin.y, editView.frame.size.width, editView.frame.size.height)];
所以是的,当你在午夜左右复制/过去代码时,请务必在早上仔细检查! :)