Avoid animation of UICollectionView after reloadItemsAtIndexPaths
It's worth noting that if you're targeting iOS 7 and above, you can use the new UIView
method performWithoutAnimation:
. I suspect that under the hood this is doing much the same as the other answers here (temporarily disabling UIView
animations / Core Animation actions), but the syntax is nice and clean.
So for this question in particular...
Objective-C:
[UIView performWithoutAnimation:^{
[self.collectionView reloadItemsAtIndexPaths:indexPaths];
}];
Swift:
UIView.performWithoutAnimation {
self.collectionView.reloadItemsAtIndexPaths(indexPaths)
}
Of course this principle can be applied for any situation that you want to ensure a change is not animated.
Custom animation on UICollectionView reload data
u can make some trick like suggested here
+ (CATransition *)swipeTransitionToLeftSide:(BOOL)leftSide
{
CATransition* transition = [CATransition animation];
transition.startProgress = 0;
transition.endProgress = 1.0;
transition.type = kCATransitionPush;
transition.subtype = leftSide ? kCATransitionFromRight : kCATransitionFromLeft;
transition.duration = AnimationDuration;
return transition;
}
and add it to your collectionView
UISwipeGestureRecognizer *swipeGestureL = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeToLeftCollectionView:)];
swipeGestureL.direction = UISwipeGestureRecognizerDirectionLeft;
[self.collectionView addGestureRecognizer:swipeGestureL];
- (void)didSwipeToLeftCollectionView:(UISwipeGestureRecognizer *)swipeGesture
{
[self.collectionView.layer addAnimation:[Animation swipeTransitionToLeftSide:YES] forKey:nil];
[self.collectionView reloadData];
}
result:
Related Topics
Applicationwillterminate: Not Being Called
New Itunes Connect Interface -- Should It Immediately Be Seen on "Prerelease"
Hide the Cursor of a Uitextfield
How to Launch the iOS Simulator from Terminal
Swift 3: Replace C Style For-Loop with Float Increment
How to Use Dark Mode in Simulator iOS 13
How to Render View into Image Faster
How to Tell What Profile/Signing Certificate Was Used to Sign .Ipa
Completion Block for Popviewcontroller
Wkwebview Causes My View Controller to Leak
How to Load Icarousel View from Storyboard or Xib
iOS Web Page Errors Over Cellular Data But Not Over Wifi? Recent Change to At&T Cellular Network
What Does the Property "Nonatomic" Mean
What's the Best Way to Add a Drop Shadow to My Uiview
Add a Child View Controller's View to a Subview of the Parent View Controller
How to Create Different User Groups in Firebase
Xcode - How to Drag a Component from One View to Another Without Losing Its Frame
Arc4Random_Uniform Not Available in Xcode 7.0 Beta (7A176X) on Osx 10.10.4