Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Initial and final layout attributes for CircleLayout #24

Merged
merged 1 commit into from

2 participants

@DmitryTsepelev

Apple changed UICollectionViewLayout API: they renamed initialLayoutAttributesForInsertedItemAtIndexPath to initialLayoutAttributesForAppearingItemAtIndexPath and finalLayoutAttributesForDeletedItemAtIndexPath to finalLayoutAttributesForDisappearingItemAtIndexPath. Moreover, these methods now called for every item in collection view, so we have to handle inserting and deleting by ourselves. I fixed CircleLayout sample a little bit.

@alloy alloy merged commit 818b3b3 into HipByte:master
@alloy
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 28, 2013
  1. @DmitryTsepelev
This page is out of date. Refresh to see the latest.
Showing with 39 additions and 9 deletions.
  1. +39 −9 CircleLayout/app/circle_layout.rb
View
48 CircleLayout/app/circle_layout.rb
@@ -24,18 +24,48 @@ def layoutAttributesForElementsInRect(rect)
(0...@cell_count).map { |i| layoutAttributesForItemAtIndexPath(NSIndexPath.indexPathForItem(i, inSection:0)) }
end
- def initialLayoutAttributesForInsertedItemAtIndexPath(path)
- layoutAttributesForItemAtIndexPath(path).tap do |obj|
- obj.alpha = 0.0
- obj.center = @center
+ def prepareForCollectionViewUpdates(items)
+ super
+
+ @deletePaths = []
+ @insertPaths = []
+
+ items.each do |i|
+ case i.updateAction
+ when UICollectionUpdateActionDelete
+ @deletePaths << i.indexPathBeforeUpdate
+ when UICollectionUpdateActionInsert
+ @insertPaths << i.indexPathAfterUpdate
+ end
+ end
+ end
+
+ def initialLayoutAttributesForAppearingItemAtIndexPath(path)
+ attributes = super
+
+ if attributes.nil? && @insertPaths.include?(path)
+ attributes = layoutAttributesForItemAtIndexPath path
+
+ attributes.alpha = 0.0
+ attributes.center = CGPointMake(@center.x, @center.y)
end
+
+ attributes
end
- def finalLayoutAttributesForDeletedItemAtIndexPath(path)
- layoutAttributesForItemAtIndexPath(path).tap do |obj|
- obj.alpha = 0.0
- obj.center = @center
- obj.transform3D = CATransform3DMakeScale(0.1, 0.1, 1.0)
+
+ def finalLayoutAttributesForDisappearingItemAtIndexPath(path)
+ attributes = super
+
+ if attributes.nil? && @deletePaths.include?(path)
+ attributes = layoutAttributesForItemAtIndexPath path
+
+ attributes.alpha = 0.0
+ attributes.center = CGPointMake(@center.x, @center.y)
+ attributes.transform3D = CATransform3DMakeScale(0.1, 0.1, 1.0)
end
+
+ attributes
end
+
end
Something went wrong with that request. Please try again.