Live data from Hacker News

On Making Socialcam's User Interface (Or, The #%$&ing Red Line)

blog.socialcam.com

1–10 of 19 posts

Re: On Making Socialcam's User Interface (Or, The #%$&ing Red Line)

#3
post #2

Couldn't you just draw the red line in drawRect of a UINavigationBar category? Then it'd appear in every navigation bar of your app, in the UINavigationBar, and not lost in some other hierarchy anywhere else.

My thoughts exactly. One reason against this is that it changes every single one of your bars. However, the way around it is to tag each navigation bar with a different number and use that conditional in the UINavigationBar category.

Though, there's probably a reason they didn't go with this. Any ideas?

Re: On Making Socialcam's User Interface (Or, The #%$&ing Red Line)

#4
post #2

Couldn't you just draw the red line in drawRect of a UINavigationBar category? Then it'd appear in every navigation bar of your app, in the UINavigationBar, and not lost in some other hierarchy anywhere else.

My thoughts exactly. One reason against this is that it changes every single one of your bars. However, the way around it is to tag each navigation bar with a different number and use that conditional in the UINavigationBar category. Though, there's probably a reason they didn't go with this. Any ideas?

Besides your point, the only other downside is that the red line is in the navigation bar, not directly below it. If it's a pixel or two tall it's probably fine but if it's 4+ pixels tall it'd probably make the vertical spacing of elements in the nav bar (titles, buttons) appear slightly misaligned.

Re: On Making Socialcam's User Interface (Or, The #%$&ing Red Line)

#6

Great writeup! Why didn't you guys just use interface builder? Not only does it speed up view building in general, but, as you claimed, it would have fixed this issue in particular.

My favorite quote on this:

"...there's no more reason to abandon IB than there is to forego compilers and write all your code with a hex editor"

http://iphonedevelopment.blogspot.com/2009/10/dont-fear-inte...

Maintaining programmatically-generated views is miserable. But with IB, it's pretty simple. Wanna nudge that button up a couple pixels? Click. Drag. Done. Want to set up label and button appearances for multiple states? A few clicks save you several lines of code per UI object. As as mentioned in the above link, every line of code you don't have to write is a line of code you don't have to maintain/debug. The converse is a huge volume of code across an app to do tedious layout stuff, which doesn't sound fun.

You also cut down on compile/debug cycles, thanks to skipping things like "Oh, fuck, I forgot to set that label's background to clearColor."

Perhaps best of all, IB will help you set up autoresizing masks for your views. This process is extremely counterintuitive to me and it's nice to be able to immediately test out my changes without having to build and run for each tweak.

Re: On Making Socialcam's User Interface (Or, The #%$&ing Red Line)

#7
post #2

Couldn't you just draw the red line in drawRect of a UINavigationBar category? Then it'd appear in every navigation bar of your app, in the UINavigationBar, and not lost in some other hierarchy anywhere else.

Unless I'm creating a completely custom view, I generally see overriding drawRect: as a dangerous idea; you're messing with Apple's implementation details and there's no way to know how it will work in the future.

Also, not every navigation bar needed to have a red line.

// edit: "overriding drawRect:" should have read "overriding drawRect: in a category".

Re: On Making Socialcam's User Interface (Or, The #%$&ing Red Line)

#8
>> There is no doubt that Socialcam looks much better with the red line in place than without. So we needed to keep it.

Let me just say that if it's that subtle a detail, you'd rather spend engineering effort on something that gives you a greater return on investment.

Is the red line going to make the program functionally better? Will it increase reliability? (It'll probably reduce it if not coded properly) Will it add significantly to user-delight?

While it is useful to know how to do what you did, this is, in my mind, a case of not knowing what to do.

Re: On Making Socialcam's User Interface (Or, The #%$&ing Red Line)

#9

>> There is no doubt that Socialcam looks much better with the red line in place than without. So we needed to keep it. Let me just say that if it's that subtle a detail, you'd rather spend engineering effort on something that gives you a greater return on investment. Is the red line going to make the program functionally better? Will it increase reliability? (It'll probably reduce it if not coded properly) Will it a…

Details are important, even if they're as minor as this one.

Re: On Making Socialcam's User Interface (Or, The #%$&ing Red Line)

#10
post #7
post #2

Couldn't you just draw the red line in drawRect of a UINavigationBar category? Then it'd appear in every navigation bar of your app, in the UINavigationBar, and not lost in some other hierarchy anywhere else.

Unless I'm creating a completely custom view, I generally see overriding drawRect: as a dangerous idea; you're messing with Apple's implementation details and there's no way to know how it will work in the future. Also, not every navigation bar needed to have a red line. // edit: "overriding drawRect:" should have read "overriding drawRect: in a category".

Overriding drawRect to do your own drawing is probably the most common thing that iOS developers do when working on custom interfaces. I'm not sure why you think it's dangerous, it's a public API call. I think almost every app developer I know who has designed a custom navigation bar has done his own drawing in drawRect for it instead of swizzling or some other more hacky method.

Re: not every navigation bar needing to have it, you could have a different UINavigationBar category in those VCs to not draw the red line, no?

Post reply on HN