Alo*_*nha 4 iphone objective-c ios uicollectionview
我正在使用集合视图,我第一次需要删除click.which正在为我工作的集合视图的单元格.但我正在努力与UIcollectionview的动画时间.它总是一样的.我怎么能增加删除单元格时减少动画时间.我也将该代码放在uianimation块中,但它不起作用.这是我的删除代码,任何建议将非常感谢,谢谢.
[self.collectionView performBatchUpdates:^{
NSArray* itemPaths = [self.collectionView indexPathsForSelectedItems];
// Delete the items from the data source.
[self deleteItemsFromDataSourceAtIndexPaths:itemPaths];
// Now delete the items from the collection view.
[self.collectionView deleteItemsAtIndexPaths:tempArray
} completion:nil];
Run Code Online (Sandbox Code Playgroud)
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
在上面的委托方法中,执行以下操作:
NSIndexPath *lIndexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:0];
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:lIndexPath];
//Perform flip animation
//_AnimationDuration defined in Constant.h
CGContextRef context = UIGraphicsGetCurrentContext();
context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationDuration:_AnimationDuration];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:cell cache:YES];
[UIView commitAnimations];
//Implementation of GCD to delete a flip item
double delay = _AnimationDuration/2;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
//code to be executed on the main queue after delay
[self deleteContent:indexPath];
});
-(void) deleteContent:(NSIndexPath *)_indexPath{
//Remove items from array on delete
[itemArr removeObjectAtIndex:_indexPath.row];
//Reload the items of UICollectionView performBatchUpdates Block
[self.collectionView performBatchUpdates:^{
[self.collectionView deleteItemsAtIndexPaths:@[_indexPath]];
} completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4751 次 |
| 最近记录: |