3 ms·
Here's why I say no it isn't: The end product, what my nib is for, has 12 labels, three UIView border bars (1px thick), two UIViews just for a differing backgr
by bennyg 14y ago
Here's why I say no it isn't:
The end product, what my nib is for, has 12 labels, three UIView border bars (1px thick), two UIViews just for a differing background color in a couple spots, and a UIImage. Now you're right, I could set all those in code, alloc all those labels and adjust their sizes and positions relative to the ones that came before and all of that jazz, and that's all fine and dandy. Until I realize that my design needs tweaking. So, instead of selecting all elements on the nib and pressing up twice for a two pixel shift, I'm sitting there editing 20 different things in a CGRect call... way more work.
So instead of doing it all in code, the way I went about was creating a subclass of UIView with a .xib file attached to it. The .xib has everything where I want it visually and it's connected to the header via properties of everything that needs to be dynamic. Then I made a custom init method that just takes in my object and returns a UIView object that is the totality of that nib loaded with the data I need it to be.
All in all, instead of bloat, every time I need to return an instance of that custom subclass I effectively call something like this:
UIView *newView = [CustomClass createCustomViewWithObject:(id)object];
And that's it - I'm free to put it wherever I want up the chain in my subsequent views.