【发布时间】:2015-07-19 03:13:41
【问题描述】:
我有一个 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];
}
}
【问题讨论】:
标签: ios cocoa-touch animation uiview uiviewanimation