Reputation: 311
Things I want to do
Duplicate a CollectionView From ControllerA to ControllerB in storyboard
Things I have done
Duplicate(CMD+D) CollectionView From ControllerA(which works fine) Drag Drop to ControllerB
retarget(ctrl + drag) dataSource and delegate to ControllerB
It should be
duplicated collectionView should work fine like it in ControllerA
But result is
numberOfSectionsInCollectionView
and numberOfItemsInSection
are called
But cellForItemAtIndexPath
not called
Edit 1
the problem looks like related to the frame size of the CollectionView
CollectionView: size(320,50) flow layout,scroll horizontal
CollectionViewCell: size(50,50)
If I drag CollectionView height to 65,it works with a warning:(cellForItemAtIndexPath
called)
the behavior of the UICollectionViewFlowLayout is not defined because: the item height must be less than the height of the UICollectionView minus the section insets top and bottom values.
if CollectionView height >= 114,works without warning.
ControllerA with same parameters size(320,50) will work.don't know why
Edit 2
if I duplicate the CollectionView with all same settings and retarget to same delegate. the duplicate one doesn't work as expected. But the original one works!! weird!!
Upvotes: 0
Views: 550
Reputation: 311
After upgrade to xcode 6 beta 5, I notice the cell is not in the visible area of CollectionView
Solution:
toggle off Adjust Scroll View Insets
option in parent view controller attribute inspector
or add this code to parent view controller viewDidLoad method:
self.automaticallyAdjustsScrollViewInsets = NO;
ref:UICollectionView adds top margin
Upvotes: 2