Re: Device/Resolution independent positioning of GUI items on iOS
Re: Device/Resolution independent positioning of GUI items on iOS
- Subject: Re: Device/Resolution independent positioning of GUI items on iOS
- From: Brian Lambert <email@hidden>
- Date: Mon, 19 Mar 2012 13:22:17 -0700
Hi Alex,
Regarding you having to "repair" code where "UI elements that have been
hardcoded in place with the approach of: Just define the CGRect and we're
all good." I think you're seeing things as being "gross" when they are not.
"Just define the CGRect and we're all good" is what IB does. A XIB file is
nothing more than a set of hardcoded values stored in XML vs. being
hand-coded in Objective-C.
For example, here's a label laid out in a XIB:
<object class="IBUILabel" id="305226376">
...
<string key="NSFrame">{{20, 20}, {280, 21}}</string>
...
</object>
And here is the same label coded in Objective-C:
...
labelMyLabel_ = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 20.0, 280.0,
21.0)];
...
The programmer who hand-coded the label didn't do anything better or worse
than the programmer who used IB to lay out a XIB file. In fact, in some
cases, it's way easier to "see" UI in Objective-C vs. Interface Builder.
In Objective-C an experienced UI coder can "see" a bunch of controls, and
all their properties, on one screen vs. having to click on each one and
inspect their properties in Interface Builder.
Best,
Brian
On Mon, Mar 19, 2012 at 12:59 PM, Alex Zavatone <email@hidden> wrote:
> In the current project that I'm tasked to repair from the previous two
> programmers, I've come across a load of UI elements that have been
> hardcoded in place with the approach of: Just define the CGRect and we're
> all good.
>
> Nothing is laid out in an xib file and sometimes the views are hardcoded
> or hardcoded relative to the rect/bounds of another view.
>
> Needless to say, there are a few issues when looking at the project on
> different versions of iOS and on different devices.
>
> At this point, so much is already created, I'm simply walking through the
> monolithic code and breaking it up into proper methods and new classes
> where necessary.
>
> So, while it's nice to take a 40+ line mess and turn it into two method
> calls, I'm not 100% sure on the preferred approach for programmatically
> positioning elements and simply hardcoding them for the delegate for one
> class of devices doesn't seem like the proper approach.
>
> Is the desired method or is there another way that I'm not seeing in the
> docs?
>
> TIA,
> - Alex Zavatone
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden