I was exploring the UICollectionView API tonight and stumbled upon an old problem. Both UITableView and UICollectionView ask their delegate for size information about the cells they display. When creating cells in separate XIB files, which I normally do, this means that the delegate must somehow know how big the root View is in that XIB. The easiest way to do that is evil: hard-code the cell’s size in the delegate. Duplication! Yuck!! No more!!!
It dawned on me that this entire problem can be avoided by doing a one-time lookup of the View’s natural size, as it exists in the XIB file (and, at run-time, in the view’s NIB). I posted a Gist on GitHub that shows my simple solution:
Happy coding!




The other day, while I was at work, my sister
stole my apple ipad and tested to see if it can survive a 40
foot drop, just so she can be a youtube sensation.
My apple ipad is now broken and she has 83 views.
I know this is entirely off topic but I
had to share it with someone!