2

我已经在视图上附加了一个点击手势,起初它似乎可以工作,但是在动画视图之后,手势被完全忽略,直到视图回到它的原始位置。

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");
}];

完成处理程序被触发,但现在点击手势完全被忽略了。

4

1 回答 1

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)];

所以是的,当您在午夜左右复制/过去代码时,请务必在早上仔细检查!:)

于 2012-05-22T09:25:22.433 回答