2012-05-22 57 views
2

我已將一個輕擊手勢附加到視圖,起初它似乎工作,但在動畫之後視圖手勢完全被忽略,直到視圖回到其原始位置。UITapGestureRecognizer在動畫後被忽略

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

,但現在的點觸手勢完全被忽略。

回答

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

所以,是的,當你在午夜複製/過去的代碼時,請務必在早上仔細檢查! :)