UICollectionView - get callback when loading is complete?

I have a UICollectionView. Each cell contains a UITextField. I want a callback when the mapping is complete, so I can request a model object for which textField should be the firstResponder, and then make it the firstResponder. Can I get this callback? Or is there another natural way to achieve this?

+7
source share
3 answers

If you send a layoutIfNeeded message to the collection view, it will update its children (adding and removing cells as necessary) before returning. This way you can sync it and then perform your actions after a reboot.

 [myCollectionView layoutIfNeeded]; [self chooseFirstResponderFromCells:myCollectionView.visibleCells]; 
+10
source

As for the actual callback method, I don't think there is one for loading the collection view. The only thing I know is performBatchUpdates:completion , and this is pretty performBatchUpdates:completion . In my experience, collective views are loading and ready to viewDidAppear by the time viewDidAppear , so I would install the first responder there.

Hope this helps!

+5
source

Never tried, but you can do this by putting the code in

 dequeueReusableCellWithReuseIdentifier:forIndexPath: 

to get the number of visible cells (possibly [visibleCells count]), and then track how many of them have actually been processed, and then call back after that. You would need to reset the count between scrolls.

Not clean, but should work. I do not know how to get a callback.

0
source

All Articles