有UICollectionView
细胞。通过点击应该添加单元格子视图。
一切正常,但是......如果我快速点击第二次或第三次,它会添加两个或三个子视图......
那么如何正确地做到这一点呢?
这是代码didSelectItemAtIndexPath
:
recipeDetailView = [[RecipeDetailViewController alloc] initWithNibName:@"RecipeDetailViewController" bundle:nil];
[recipeDetailView.view setBackgroundColor: [UIColor colorWithPatternImage:[UIImage imageNamed:@"bgRecipe.jpg"]]];
[recipeDetailView.view setFrame: myFrame];
[UIView animateWithDuration:0.3
delay:0.0
options: UIViewAnimationOptionCurveLinear
animations:^{
[recipeDetailView.view setFrame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:recipeDetailView.view];
[self addChildViewController:recipeDetailView];
[recipeDetailView didMoveToParentViewController:self];
}
completion:^(BOOL finished){
[recipeDetailView slideViewAdd];
}];