AutoLayout: Interface Builder vs code

I haven’t blogged here for 10 years but now I return … to blog mainly about iOS programming! Or so the plan is.

I’ve been an iOS developer on and off for about 5 years now and when AutoLayout first appeared I avoided it as long as I could. My first memory of trying AutoLayout with IB is getting quickly frustrated trying to add constraints that didn’t do what I wanted and the default ones doing the opposite of what I wanted. So back to code it was.

Time has passed and I’ve become not quite an expert in AutoLayout but certainly proficient in it. Every so often I read a blog post or article about the wonders of IB + AutoLayout and how it halves your time creating layouts, gives you flexibility, cooks dinner for you, does the dishes afterwards and so on. Finally I found a bit of time to kill but with no one to kill at hand, I thought I’d give the IB side of things another go.

Everyone agrees there are downsides to IB, for example with source control and merging, but do the pros outweigh the cons?

In short, no. Why? Read on dear sir and all will be revealed!

There are a number of strange quirks in the IB interface that make things unintuitive, such as:

- The first thing you notice is that all the constraints get lumped together in a haphazard order making them hard to read.

- You can click a view to reveal only the constraints applying to it but you can’t delete them here; it is necessary to do this in the massive clumped list noted prior.

- By default views don’t have meaningful labels. In my view, once they are connected the label in IB should match the property name. Instead you have to manually name everything twice.

Views named view

Views named view – that’s intuitive!

- For some reason the Pin button doesn’t allow you to pin to a superview; you must use the menus for that. Why?

Another problem is conceptual: in code, you soon learn to ignore frames entirely when constructing layouts. In IB however, it tries to honour the initial frames you place your views in, and defaults the constants in your constraints to suit. This seems bizarre to me. I thought the idea of AutoLayout was to not concern yourself with frames?

But for me, the real IB killer is building constraints with visual format language. If you want to have several views in a vertical list, in code you can do so with one formatting string:

@V:"|[view1][view2][view3][view4][view5]||"

and done!

In IB you manually have to create each constraint and then edit each of them because again the Pin button doesn’t provide enough options.

For a layout of any complexity I’d bet on coding to outrace IB hands down.

I know some prefer IB because there’s less code, but come on: we are programmers. Afraid of code we should not be.

So what do you think? Is coding layouts better or is there a magic feature in IB that I’ve overlooked?

Posted in Uncategorized | Tagged , , , | 1 Comment

*** STOP PRESS *** My Opinions Are Important moves to its own domain!

That’s right people – this blog is moving to its own domain and its own space. Check it out!

The new address is myopinionsareimportant.com

The feed address is now http://myopinionsareimportant.com/?feed=rss2

Please update your links/bookmarks/feed readers accordingly.

All the posts and comments have been ported across, so you can read them all again – and again – and again!

See you all over there.

STRANGENESS UPDATE: Hmmm, apparently new blog now thinks its feed address is http://myopinionsareimportant.com/feed. Why did it change? Not sure, but if you have problems with the feed=rss2 address, try the other one instead.

Posted in Important Announcements | 2 Comments

Great gifts for geeks

TheMolk found some excellent off-the-wall gift ideas at ThinkGeek, including a tiny remote-controlled helicopter and a tiny, yet fully functional Japanese battle tank.

tank.jpg

A great gift idea, and oh-so-handy next time World War III erupts in your home or workplace.

Posted in Interesting, but otherwise unclassifiable, Nutbar | 2 Comments

Wedding gifts for the strange: spider bowl

From Laura Zindel Ceramics, as featured on bioephemera:

spider_bowl.jpg

You are probably asking yourself why. Zindel’s explanation:

I hope that I can make art that a family member can buy to be handed down the line. Something bought on a whim, that becomes the platter for the turkey, or sits on the mantel. “Crazy old Uncle Larry bought that peculiar spider platter, and we just can’t seem to part with it”, I would like to be apart of that.

There’s also beetles, snakes and cicadas, oh my.

Posted in Nutbar | 7 Comments

Top 5 Science Experiments On Cats

** This blog has moved to myopinionsareimportant.com **

Tell me you’re not at least a little disturbed by the following:

#1: Cat-O-Vision
A team of scientists hacked into a cat’s brain and created a video of what the cat was seeing.

#2: We Have Ways Of Making You Purr
Restricting sleep to two hours a night, enforced by use of a treadmill. Sounds like a Guantanamo Bay interrogation technique, does it not? No, this is science. You’ll be pleased to know that restricting sleep results in a greater proportion of REM sleep in cats.

#3: Cats In Spaaaace
How do cats react to zero gravity? Do they handle it better than dogs? This is the scientific question of our times and only now has it been answered.

#4: I’m Not Hungry. (Bzzt.) Actually, I Am.
Scientists obtained complete control over a cat’s mind. By remote control, they could make the cat hungry, thirsty, or itchy, or even make it more aggressive or affectionate. Note that they did not force the cat to eat; they only made it desire to eat.

#5: Just Gimme One More Bowl
Do cats prefer spiked milk to ordinary milk? Only science could provide the answer. A series of experiments was performed that subjected cats to extreme stress until they became alcoholics, or masochistic, deliberately exposing themselves to repeated electric shocks.

BONUS: The Scratching Post Is Melting
Giving LSD to cats. Does this qualify as science? Discuss.

(This post is at least partly inspired by the Top 5 Group Writing Project at ProBlogger.)

Posted in Cats, Nutbar, Random cat-related Internet stuff, Science | 34 Comments

Deep & Meaningful Festival explodes onto the blogosphere

** This blog has moved to myopinionsareimportant.com ** 

Thank Robert Hruzek for this. His group writing project asked participants to write an article on a life lesson they learned from an unusual source. All told, there were 16 entries.

Here is the complete list of entries, each one finishing the phrase “What I Learned From…”

“… Teen Girl Squad”, by Markk at My Opinions Are Important
WOW! You’ll laugh, you’ll cry, you’ll cheer. Top post. Top, top post.

“… the Mt. Pinatubo Eruption”, by Ronald Huerca at Ronalfy.com
Most of this has nothing to do with volcanic eruptions, but worth the read all the same.

“… Drugs”, by Sam Brougher at Forest Azuaran
Legal drugs. Strong legal drugs that do strange things to your emotions and memory. Reminds me of a friend’s experience with oxycodeine (“The walls are melting …”).

“… a Mesquite Tree”, by Mike DeWitt at Spooky Action
You are limited only by your willingness to be bold. That, and mesquite trees are weird.

“… Drinking Starbucks Coffee”, by George Manty at Can I Make Big Money Online
The main thing I learned from drinking Starbucks coffee is not to visit Starbucks. That’s not what this post is about though :) Useful for those of you who run a business.

“… My Wife!”, by Rajaram Sethuraman at Thoughts of a Rambler
One man learns that he is a fashion disaster, among other things.

“… Having a Daughter”, by Marco Richter at FitForFreedom
How to not worry about being in debt.

“… Norm”, by Joe Raasch at The Happy Burro
Getting the most out of each moment in life.

“… my mentors”, by Karin H. at The Kiss Business Too
Two mentors, and what Karin H. learned from them.

“… Procrastinating”, by Yvonne Russell at Grow Your Writing Business
This piece will inspire you to procrastinate more often, if you could be bothered. Perhaps later on.

“… a Squirrel”, by G.L. Hoffman at What Would Dad Say
A nice story, with a zinger at the end.

“… Blogging”, by Gayla McCord at Mom Gadget
Someone who makes money by writing 12 blogs talks about that, and why she doesn’t go insane writing so much. Very informative.

“… a Weight Problem”, by Monique Attinger at Insurance Guide 101
Learn about overcoming a weight problem, and also about insurance. What more could you want?

“… Taking Out the Garbage”, by Michael Chantrel at Mortgage Guide 101 Blog
Why taking out the garbage is just like paying off a mortgage.

“… RUMMAGING!” by William Tully at LOGICal eMOTIONs
Looking at a product at the end of its life cycle, and winding the clock back.

“… A Light Switch”, by Robert Hruzek at Middle Zone Musings
When Cooking Goes Bad, or why you learn most about someone by viewing them when things go wrong.

Posted in Blogging, Deep & Meaningful | 3 Comments

1984 arrives in Britain in 2007

1984-movie-bb_a1.jpg

According to Spiked Online, those CCTVs that have become so ubiqitous in the UK have now been rigged up with loudspeakers, allowing remote faceless government agents to tell you not to loiter, or litter, or whetever.

But who will be doing the voices? Children, that’s who. The government has issued a press release stating the following:

‘Children from across the country will be very publicly calling upon the small minority of people who think it is acceptable to act anti-socially on our streets and in our towns to change their ways and take responsibility for their actions….’

Is the British Government trying to emulate 1984? Let’s take a look:

  • Loads of cameras following your every move? Check.
  • Cameras that can talk and give orders? Check.
  • The transformation of children into government spies? Check.
  • Government surveillance inside private homes? Not yet, in the UK anyway.
  • Use of torture to break “thought criminals”? No, thank God.
  • Anti-Sex League? Erm, no.

In short, the British Government is emulating 1984 as much as it is possible for a democratic government to do – so let’s hope it goes no further. If we ever hear Tony Blair say “We’re at war on terror. We’ve always been at war on terror.” than you will know they have crossed the line.

(If you haven’t read 1984, read it online – and shudder.)

Posted in Communism, Evil, Rants, Tech | 2 Comments