-1
我有一個UIView動畫從左邊帶來一個UIView到屏幕上,該方法正在快速連續地從條形碼掃描引擎觸發,該方法正在觸發然後再次觸發,因此它從屏幕上移開。UIView動畫被調用兩次,取消動畫
-(IBAction)showDetailModeView
{
if (detailModeViewON==FALSE)
{
[UIView beginAnimations:@"move buttons" context:nil];
[UIView setAnimationDuration:.3];
[detailModeView setFrame:CGRectMake(0, 0, 320, 568)];
[UIView commitAnimations];
detailModeViewON=TRUE;
}
else
{
[UIView beginAnimations:@"move buttons" context:nil];
[UIView setAnimationDuration:.3];
[detailModeView setFrame:CGRectMake(-320, 0, 320, 568)];
[UIView commitAnimations];
[self stopScanning];
scannedONCE = FALSE;
detailModeViewON=FALSE;
}
[self.view endEditing:YES];
}
是否有某種方式我基本上可以說,如果這個方法在最後5秒內被調用,不要做任何事情。
僞代碼
-(IBAction)showDetailModeView
{
if(UIVIEW animation was triggered longer than 5 seconds ago)
{
if (detailModeViewON==FALSE)
{
[UIView beginAnimations:@"move buttons" context:nil];
[UIView setAnimationDuration:.3];
[detailModeView setFrame:CGRectMake(0, 0, 320, 568)];
[UIView commitAnimations];
detailModeViewON=TRUE;
}
else
{
[UIView beginAnimations:@"move buttons" context:nil];
[UIView setAnimationDuration:.3];
[detailModeView setFrame:CGRectMake(-320, 0, 320, 568)];
[UIView commitAnimations];
[self stopScanning];
scannedONCE = FALSE;
detailModeViewON=FALSE;
}
[self.view endEditing:YES];
}
}