Manipulating UIButton contents

On iOS, the UIButton class presents a title, image, or both as a clickable element. By default, the text is to the right of the image, but you can adjust the position with theimageEdgeInsets and titleEdgeInsets properties. So far, so good.

The icons for my buttons are all the same size and the image is centered by default, so I am able to use constant insets for the image to move it to the upper half of the button. The text is a differnet story, though! Depending on the language, the text might split to more lines in its default location than it will need in the final spot. A simple static inset won’t work for me. If the insets need to be dynamic, I need to know what those insets are inset from. The titleLabel has a frame, which seems like the right thing to us, but it turns out not to be stable. After rotating the device, the text was all messed up.

After much gnashing of teeth, I discovered that the titleLabel.frame isn’t a true frame at all. It’s the frame with the insets already applied! Solution: do some math to un-apply the insets or set them to zero before checking the frame.

You’re welcome.

The Mystery of the Missing Mail

A few months ago, I started to suspect that something is rotten in the state of my email setup. I have a personal domain which forwards email for my wife and I to our gmail accounts. That way, we let google store/serve my email without being tied to a address. This has worked very well, but recently, my wife and I both discovered that some messages were simply going missing. They made it to our domain host, but the forwarded messages never arrived at our gmail accounts. The same senders could send email directly to our accounts, though!

This evening, I discovered the existence of SPF records, and they explain all of the trouble!

Briefly, SPF records specify which hosts are authorized to send email on behalf of a given domain name. So, if you have an SPF record, it prevents spammers (who don’t have access to your mail host) from masquerading as you. Nifty.

Except. It breaks forwarding because my email host is now sending email to google from a  whole bunch of domains (everyone who sends me mail). Google is looking up the sending domain’s SPF record, and if it has one, my host isn’t going to be on the list.

Now, Google really shouldn’t ACCEPT these messages and then drop them: it should REJECT them. However, now that I know what’s happening, I can fix it.

Or can I?

As far as my research has taken me, it seems there is no provision in the SPF documentation for email forwarding. It would require the forwarding host, instead of accepting the incoming mail, to respond with a redirect command of some kind. Since none of the existing SMTP instances support such a thing, the redirect would need to look to old mailers like a rejection. Of course, at least then we wouldn’t have mail getting dropped on the floor.

So it seems that, at least for now, the only way to get your email delivered is to not forward it to a mail host that honors SPF records. For me, that means either not using gmail for storage/service or using Google Apps to host my domain’s email directly.

Goodbye, Dodger

Today, we lost our dearest, precious Dodger. He died suddenly of a ruptured tumor of the liver and while the suddenness means he had little pain, it caught us unprepared.

We are, of course, devastated. Dodger was ever-loyal, ever-hopeful, curious and very smart. He had an old soul and a special intuition, and anyone who knew him could tell you he was extraordinary. Losing him leaves a gaping hole in our hearts. We will never be the same pack. He leaves us, however, with some important lessons that we will try to take ever more into our hearts. 

Work. When our girls arrived, Dodger stopped sleeping in our room and took up a post under their cribs. Later, having associated our ovens with the smoke alarm, he would try to shepherd us out of the house whenever we’d turn the ovens on. He always knew where he could serve our pack best.

Celebrate. When Dodger was a happy dog, you’d know. He celebrated life’s joys and embraced the moment. When especially happy, he’d bring his fuzzy soccer ball to show you. Imagine how much richer our lives would be if we could fully appreciate the joy that comes our way.

Love. Dodger had nothing but love for everyone he met. As much love as we sent his way, he sent back ten times that amount. If anyone was sick or sad, he was at their side. Love was Dodger’s principal tool for getting his job done.

Dodger was a bright, shining light, and one of the great positive forces in our lives. Our world is very much darker today. 

Farewell, my best friend, my faithful companion, my little brown shadow. Now you live in us.