Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView -- get a callback when load is complete?

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

like image 744
William Jockusch Avatar asked Jun 25 '13 02:06

William Jockusch


2 Answers

If you send the layoutIfNeeded message to your collection view, it will update its children (adding and deleting cells as necessary) before returning. Thus you can make it update synchronously, then perform your post-reload actions.

[myCollectionView layoutIfNeeded];
[self chooseFirstResponderFromCells:myCollectionView.visibleCells];
like image 100
rob mayoff Avatar answered Sep 22 '22 06:09

rob mayoff


As far as an actual callback method, I don't think there is one for collection view loading. The only one I know is performBatchUpdates:completion, and that's pretty unrelated. In my experience, though, collection views are loaded and ready to go by the time viewDidAppear is called, so I would set the first responder there.

Hope this helps!

like image 20
architectpianist Avatar answered Sep 23 '22 06:09

architectpianist