Re:Your First iOS App – 100% Programmatically
by jakebellacera on Tuesday April 16, 2013 @03:26PM
(#5560252)
> Maybe it's a matter of how you think, but I can "see" the changes when I adjust the frames, colors, padding, resizing masks, and that's basically all IB will do for you.
I know what you mean. I'm not an iOS/Cocoa dev by any means, but when I write CSS I typically know what the outcome is going to be in my head because I've done it so many times.
Re:Your First iOS App – 100% Programmatically
by jcampbell1 on Tuesday April 16, 2013 @04:53PM
(#5560820)
I can see it in both code and interface builder. Doing it in code on iOS is like using CSS where the only selector is `#id` and there are no child selectors. Would you write CSS if you had to do this?
#username-label { text-align:right }
#first-name-label { text-align:right }
...
#last-name-label { text-align:right }
#address-label { text-align:right }
With CSS, you get nice things like: #user-form label { text-align: right }
iOS code looks more like the first example but it goes on for hundreds of lines. You can create something like classes by creating real classes, but then you end up with inheritance hell.I find IB's WYSIWYG to be a lesser evil.
Re:Your First iOS App – 100% Programmatically
by SeoxyS on Tuesday April 16, 2013 @08:05PM
(#5561735)
Or you could use a loop :).
for (UILabel *l in @[self.usernameLabel, self.firstNameLabel, …]) {
l.textAlignment = UITextAlignmentRight;
l.textColor = [UIColor redColor];
}
Re:Your First iOS App – 100% Programmatically
by bennyg on Tuesday April 16, 2013 @09:54PM
(#5562169)
Or use a helper class (called Design.m/.h) with a call:
+(void)styleLabelForCertainPage:(UILabel *)label {
label.textAlignment = UITextAlignmentRight;
label.textColor = [UIColor redColor];
}
Then run those through your loops. If you're seriously considering writing a lot of lines for something trivial, then you're probably doing it wrong in Objective-C.
Re:Your First iOS App – 100% Programmatically
by BHSPitMonkey on Tuesday April 16, 2013 @05:56PM
(#5561198)
If your iOS code comes out looking that repetitive, sub-optimal code organization is probably the real culprit.
Re:Your First iOS App – 100% Programmatically
by smj2118 on Tuesday April 16, 2013 @08:12PM
(#5561761)
What about UIAppearance? You can specify appearance for a UILabel inside a specific container type.
Re:Your First iOS App – 100% Programmatically
by sjdev on Tuesday April 16, 2013 @10:22PM
(#5562268)
I love UIAppearance. I am not too well versed in CSS but UIAppearance adds a lot of what I have seen done with CSS. You can change the default appearance of most default elements really easily, and declare containers inside of that with a whole different set of defaults. It makes styling your app a really painless process. All you have to do to make all the UIToolbars in your app red, for example, is use this one line at the start of your program.
[[UIToolbar appearance] setTintColor:[UIColor redColor]];
Re:Your First iOS App – 100% Programmatically
by manmal on Tuesday April 16, 2013 @06:27PM
(#5561372)
You could write generator/setter methods for aligning labels to the right, no need for inheritance here. But, smart categories and inheritance go a long way. The last time I tried IB, I really regretted it because I constantly had to click through all those element layers (object hierarchy inspector is not that good either). After about 2h I gave up and rewrote everything to code-only.
I can write UI code faster than any developer I've ever met who uses IB, and that's doubly true for class hierarchies I have subclassed for multiple apps, and triply true when it comes time to change those subclassed hierarchies. You note that IB is for simple UI layouts, but I would argue that for layouts that simple, the code is simple too.
Maybe it's a matter of how you think, but I can "see" the changes when I adjust the frames, colors, padding, resizing masks, and that's basically all IB will do for you.
IB will also happily confuse your localization effort, and introduce bugs when you ship apps with unreferenced XIBs.