Sticky Footers with UITableView

The Problem

Last week, I had to implement sticky footers in a table view. Sticky footers are where the footer comes at the end of all the table contents, but if the contents are such that the scrollable content height of the table view is less than the height of the view, the footer will still appear at the bottom of the view.

Non Sticky Footer

A non-sticky footer

A sticky footer

A sticky footer

I searched for a solution to this, but all I found were solutions where the footer was always at the bottom of the view. That’s pretty easy to solve. You just use a UIViewController and put a UITableView and your footer view into the view controller’s view, lay it out properly and you’re good to go. In this scenario, the footer never scrolls and is always visible. That’s not the kind of sticky footer I needed.

The Solution

The solution I came up with was to stick my footer view into another view that I used as the UITableView’s footer. Let’s call it the main footer view. You then resize this main footer view depending on the scrollable content of the table. If the scrollable content height is greater than the tables view’s visible height then no need to do anything. The main footer view and my footer view are the same size. However, if the content height is less than the visible height then you just resize the main footer view to occupy the remaining space.

The Code

First, I added a propery to my UITableViewController subclass:

@property (nonatomic) BOOL footerNeedsLayout;

Then I overrode viewDidLayoutSubviews:

What this does is recreate the footer and position it after everything has been laid out. What this means is that whenever your data changes and before you call reloadData on the table you should set footerNeedsLayout to YES.

This could have been done with programmatic constraints and let AutoLayout take care of it, but I chose to do it this way as it seemed to be a simpler solution and easier to get done in the time constraints I was under. Plus I wanted the compliance footer to be a reusable component and didn’t want to duplicate the UI all over the storyboard for the app.

Adding the footer works like this:

Notice that we do set the autoresizing masks of the compliance footer and the main footer so that AutoLayout will generate the correct constraints.

Finally, here’s the code to compute the frame for our main footer view:

We just compute the visible space of the table view (its height – its content insets). If the height of the table view’s content is less than the visible space – the footer height then we adjust the footer to fill up the empty space. Otherwise we leave the footer alone.

It wasn’t as hard as a thought it would be. A better solution would be to use layout constraints in such a way that the footer wouldn’t have to be constantly recreated and repositioned whenever the data changes.

Back to WordPress

You’ve probably noticed that my blog has changed again. I’ve moved back to WordPress from Octopress. I could never find a plugin for Octopress that did image captions right. I spent way too much time on it and just decided to use something that just worked. I looked at a lot of static blogging engines and they all had their issues.

With WordPress, I have to use the web based editor, but it works and their is a lot of plugins and support behind it. I have better things to spend my time on. To make things better, I think I’ll try Desk. I’ve also installed the Markdown plugin, so I can continue to use it.

This has also got me thinking. Wouldn’t be nice if there was a Mac app that provided a nice writing environment (with Markdown of course), and then would generate your static website, without having to use the command-line or be a programmer? There used to be an app from Fog Creek called City Desk that did this. Maybe I’ll create this app.


App: The Human Story – My Story

There is a Kickstarter project that was started recently for a film titled App: The Human Story. It “is the story of the cultural phenomenon that touches all our lives.” It is about the people who make apps. Many of them are people I follow on blogs, and listen to on podcasts, and look up to. I simply had to back the project, and I did.

The producers of the film, on their blog, have asked that others involved in apps write about their own stories. This is my story.

Even though the popular term “apps” has only been in widespread use since 2007, in some way, apps have been a part of my life for over 35 years. For me, it started in 1977, when my Dad bought an Apple ][+ and brought it home. Almost immediately, I found the BASIC manual that came with it and started going through it page by page. I finished it in two days. Back then apps were simply called “programs”.

Your first programs are always very simple. In BASIC, it was probably something like this:

Which would print HELLO forever until you typed Ctrl-C, causing the program to be aborted. Back then there was no lowercase available. That came later with the Apple //e and an 80-column card that extended the width of the screen from 40 to 80 characters.

I don’t know what it is about that simple program, but when you type it in and then type RUN, something magical happens when you do it for the first time. You realize that you are in control. You can make the computer do whatever you want. It opens up a whole new world.

That was the start of my story. From there, I probably spent most of my time learning Applesoft BASIC. I would read Nibble magazine and type in the listings of programs I was interested in. Listings were the source code of a program in BASIC. They were pages and pages long. It would take hours or days to type them in. Many times, you have a typo, or other error and you would have to track them down. That was my first experience with debugging. Sometimes the listings would have 6502 assembly programs. So I learned a little of that too.

I advanced and wrote my own programs or apps. One of my first was a program to keep track of all my little league baseball stats. For each game I played, I would enter my at bats, hits, as well as fielding chances and errors. I could then see what my batting average and fielding percentage was for the year so far. It was a menu driven app, which was the fashion back then. All your commands were executed by navigating through a set of menus.

In 1984, the Macintosh came out and shook up the world. Now programs were called “applications” and they had graphical user interfaces, or GUIs. A little later you could buy a mouse for the Apple //e. You could write programs that could use the mouse. I started to implement a menu bar on the Apple // in 6502 assembly. I got it partially working but never completed it.

In college, I bought myself a Macintosh SE with a 20MB hard drive. I used it to remotely dial into the University of Utah’s computer systems to do assignments and, of course, write my own applications. I had learned Pascal back in high school and used it to write a tennis ranking system for college tennis. I took the Artificial Intelligence series of classes and used Lisp for a whole year. I came in 4th in the rover competition. We wrote AI programs to control simulated rovers. I think this was the beginning of NASA researching how they might control a rover on Mars. This was about 1990.

Always, my dream was to start my own software company and make a living selling applications. I wrote a Numerology program for the Mac using THINK C and the THINK Class Library (TCL). I never tried to sell it though. Back then you had to go through a publisher and get it in the store. I really had no idea how to do that.

This was the 90s and Apple wasn’t doing so well. I couldn’t get a job writing Mac applications so I moved to the Windows world. I still followed Apple, and, of course, I followed NeXT, the company that Steve Jobs started when he left Apple.

The first time I saw a demo of Interface Builder, I was amazed. I had to get it and use it to write applications. Interface Builder was NeXT’s tool for creating GUIs. You simply dragged buttons and other components onto the screen and set their properties. You could even create instances of non-GUI objects and then connect GUI objects to non-GUI objects to actually do something. One of the demos even showed how to do something useful without writing any code. You could connect a text field to a slider and then as you moved the slider, the text field would get updated with the value of the slider. If you entered a value in the text field, the slider’s position would update.

I believe the term “app”, originated with NeXT. NeXT applications were actually folders, called bundles, that had an extension of .app. This told the operating system to treat this folder as an application. Long before “app” became a household word, the Apple and NeXT communities used the term “apps” or “app” as a shortcut for “application”.

I dove into learning all I could about NeXTSTEP, NeXT’s application framework or software for writing apps, and learning Objective-C, which was an object-oriented language that was used to write NeXT applications. In 1993, I went to NeXT World, and I get a free copy of NeXTSTEP for 386. It would run on PCs, but you had to have just the right configuration. Mine didn’t meet it. Before then NeXTSTEP only ran on very expensive NeXT machines that I couldn’t afford. So all I could do with NeXT development was read about it. I did however implement a simple version of the Objective-C runtime at my job. I recreated as much as I of the THINK Class Library and used it to write object-oriented programs at work in C. I even had others using it. It worked pretty well.

Finally, Apple bought NeXT, and Steve Jobs came back to Apple. When OS X came out for the Mac in 2000, I knew my time had come to finally get to develop using NeXTSTEP, or Cocoa as it was now called. I bought a Mac Powerbook and started to learn Cocoa development.

In 2003, I started infiniteNIL Software. I began writing Cocoa software full-time, writing my own apps and doing contract work.

The first Mac Cocoa app I wrote and sold was PhoneWord. With PhoneWord, you entered a telephone number and it would tell you all the phrases that you could make with that number. For example, the number 555-3865 could be turned into 555-DUNK. Each digit in a number has letters associated with it and you substitute a letter for a number and see if you can make a word.

Another app I wrote was Packrat, a desktop client for 37signals’ (now called Basecamp) Backpack web app. Backpack was a personal information system.

These apps I tried to sell on my website. I would upload them to MacUpdate and other download sites.

Apple became more and more popular again with the release of the iPod and people switching to Macs either because they liked the iPod and they wanted more products from Apple or because they were tired of all the problems with Microsoft Windows. More and more software developers, like myself, “went indie” to write their own software and sell it on the internet.

Then in 2007, everything changed again. Apple announced the iPhone. I bought it right away because I wanted to write apps for it and it was a very cool device. I remember be crazily excited during the announcement. It was pretty much everything once could imagine in a device. In 2008, when Apple announced Cocoa Touch, the SDK for the iPhone, we all were very excited. We could finally use the great Cocoa frameworks to write iPhone apps.

My first app, Numerology, was released when the App store opened for the first time. Earlier, I had written it for the Mac, and this time I brought it up to date for the iPhone. Over the years, Numerology has done way better than I ever expected. It started slow and at one point it got to the point where I completed lived off my Numerology earnings. That lasted until 2012. Since then it has decreased, but it still pays my mortgage.

Other apps I have released are:

  • PhoneWord, the iPhone version of the Mac app I wrote earlier
  • Numerology: Baby Namer, an app that used numerology to help you name your new baby.
  • Favors, an app that lets you give IOUs to people that they can add to their Passbook. Apple rejected this app, saying my IOUs didn’t meet the definition of coupons that could be added to the Passbook.
  • Pitching Radar, an app that tells you how fast a baseball pitch is and lets you record pitches, keep track of the average speed and pitch count, and generate a report. Pitching Radar is written with RubyMotion.

PhoneWord, Favors, and Baby Namer have all been discontinued. Favors was rejected by Apple, and the others just haven’t sold well. Pitching Radar shows promise, and Numerology is my best seller.

Even though I haven’t been a great success at selling apps, the dream lives on. I do more contracting work now and there is a thriving job market for iOS developers. I still have ideas for apps and hope to find that one app that will let me go completely “indie”, and forge my own destiny. It has always been my dream and probably always will be.

A New Start

If you haven’t noticed, my weblog has a new design and new content. I have switched from WordPress to Octopress and have used a new theme. So far, I like it. It’s nice to be able to use Markdown instead of some slow web tool to write my posts.

My old blog was mostly political commentary and I’ve decided to remove that. Some of my most popular posts were the posts about my sabbatical that I took in the summer of 2002. Those, I have preserved and ported over to the new system. I enjoyed reading them myself. You can find them in the Sabbatical category.

Going forward, I would like to focus more on technical articles. Occasionally, I might talk about some personal interests. I will avoid political commentary. There’s enough of that on the web and it really doesn’t accomplish anything or help anyone.


The Sabbatical is Over

Today is officially the last day of my sabbatical. Friday was my birthday and Monday is the day to begin anew. I had hoped that my sabbatical would bring spectacular changes to my world, but it did not. However I still think it was a good thing. It gave me a lot of time to reflect on what I want to do with my life and it helped me come to peace with how things are. I believe I’ve grown spiritually and am more at peace with myself. I am increasingly interested in Zen Buddhism, which seems to suit me particularly well.

I’ve come to accept my fate as a bachelor, but I am confident that in due time that Fate will choose for me when that is finished. From the people I’ve talked to that is how it works for most people, especially when it works well. You can’t choose or control Love. It chooses you. Zen and the Art of Nothing is my plan. For some reason Fate has left me alone later than most people. I think I understand why and when Fate makes it move, I’m sure I will no longer think I understand, but will just know.

I’ve decided to stay in Salt Lake City because wherever you go there you are. As my experience showed in Texas, things are pretty much the same everywhere. In Salt Lake, I have a lot of friends and am well placed in the career and the recreational activities I enjoy. Plus I enjoy a high standard of living. No need to upset that. I’m going to start my own business and Salt Lake is the best place for me to do it. There is actually a highly placed Zen Master in Salt Lake ( I’m thinking of checking it out.

I’ve decided that I no longer want to be held prisoner by the whims and desire of an employer. I want to build my own company and my own products according to my own vision. I envision a company whose primary mission is to produce useful products for people. A company whose secondary objective is to have fun and to make its employees better people. Sure money is important, but its role is a supporting one. It allows us to produce products that make people’s lives easier and it allows us to enjoy life and become better people. We will not be a company that chases money at the expense of everything else and we will not be held accountable to other’s who want nothing more but to make money. We will not be going public.

This is my vision and it will take a lot of effort and time to realize it. I’ve decided to name my company infiniteNIL. Another Zen idea where to fully understand something you must first completely empty your mind of any preconceptions you have of it. Then you just experience it. Only then will you truly understand it. Plus it has a technical flavor to it, with NIL being a programming term for a nil pointer, which is a pointer to nothing or an empty pointer. My first step will be to find contract work and make enough money to pay the bills and support my vision. If you ever come across someone who needs some programming done or just some technical advice, please keep me in mind. You can always reach me personally and at the company web site ( The site isn’t much yet, but keeping watching it. It will certainly be growing.

I want to thank my friends and everybody who has supported me along the way. From people who let me stay with them like Dez and Julie, Ron and Roe, Arthur and his family, Patricia, Robert, and Christine, to friends who were just there when I needed a friend, like Jo, who’s genuine concern for everybody is just amazing. Last but not least, is my parents, who’s continuing support, no matter what I do, continues to surprise me. Thank you all. I hope you all come to Salt Lake some time so I can return the favor.


Texas Tour – Lubbock Again

Wednesday, August 14th, 2002

Wednesday morning I got back in the Jeep and started my trip home. My plan was to stay the night in Lubbock, then Albuquerque for a day with my folks and then back home. I got to Lubbock in the afternoon, but Patricia and Robert weren’t there. Instead, I was greeted by their 16 year old daughter, Christine. On my previous visit, Christine had been in Vietnam, where she had been for the last 6 weeks. Her parents had told me a lot about her as most parents do. Patricia had described her as “16 going on 25″.

It was a little awkward at first, but gradually we got used to each other. Christine informed me that her mother had told her that it was her job to entertain me. My first thought was “this will be interesting”. I will respect her privacy, but suffice to say Christine has had a lot more experience on the more “wild” side of life, shall we say than me. Which in and of itself is pretty strange since I’m 33 years old and she is 16. I wasn’t quite sure what to expect. I even thought that I might find myself in some circumstances I wasn’t comfortable with.

We went to dinner at an Italian place. Afterwards we decided to go shoot some pool and then go to a movie afterwards. We only had time for one pool game and then headed off to the movies. On the way, Christine explained that she wasn’t really into movies and she would rather do something else. To my surprise, she suggested going home and talking. By the time we got home it was probably close to 10pm. We walked out to the lake and plopped down by the steel house. It was a beautiful night and the stars were out. We proceeded to talk about life and how we both felt about our respective situations and had a wonderful conversation. We finally came in after midnight. It was a wonderful experience and something I look back at with amusement and wonderment. I had just spent the evening talking to a 16 year old about life and what it meant and the amazing thing was that she actually got it and that we actually were able to have this great conversation despite the differences in our ages and life experiences.

The next morning I had breakfast with the whole family and Robert was on a roll. Making jokes and causing us all to laugh. This continued at lunch where I went to the local deli with them. I was having such a great time and Patricia was persuasive, so I just had to stay for lunch.

Looking back at the summer, my time with the Bruno’s, just outside of Lubbock was the highlight of it all. To you, the reader on the outside it might not seem worthy of that. But to me and what I was looking for and feeling, it most definitely was.


Texas Tour – JFK

Sunday, August 11th, 2002

Sunday morning I decided to go downtown and check out the JFK museum. John F. Kennedy was assasinated in Dallas on November 3rd, 1963. I wasn’t alive then, but I can imagine and I believe that it was a day that affected America even more than September 11th. Here was a president that many people admired and looked up to. Shortly after he was assasinated the decade of the 60’s went into full swing and changed America forever. Vietnam, the assasination of Robert Kennedy and Martin Luther King, race riots, the drug culture. All these things occurred and much more. America was never the same.

I parked downtown and one of the first things I came across was the JFK Memorial. You wouldn’t know it if it didn’t say John F. Kennedy on it. A rather bland and strange memorial for such a popular figure and major event in American history.

JFK Memorial

The JFK Memorial

Next was Dealy Plaza, the place of the actual event. I walked the Grassy Knoll and the area behind the fence, where rumors persist there was another shooter. On the road where the fatal shot occured is an X to mark the spot. There is also a round plague next to the sidewalk across the street from the spot that marks it as an American historical spot. However, it says nothing about the historical event it marks. Very strange. Crowds gather around speakers still arguing and selling books that say there was a conspiracy. The whole area has a little ominous feeling that something is not quite right.

Grassy Knoll

The Grassy Knoll

Next, was the JFK museum, which is in the old Texas book repository where Oswald supposedly fired the shots. It tells the history of the president, of his administration, of the fateful day, and of the world’s reaction after the event. For not being alive at the time, it still had an emotional effect on me. Personally, I believe JFK was assasinated to stop him from doing something that the establishment didn’t want him to do. I feel that when he was killed America suffered a near fatal blow to her founding ideals. It was the beginning of where we are now.

There was also a section that showed Pulitzer Prize winning photographs of important events around the world including September 11th. Also very emotional. It brings home the point of how fortunate we are here in America. In a lot of places around the world, life is a lot more difficult.

Even though it did affect me emotionally, it was also a little disgusting in a way. Here was a little industry set up around the death of a man. It seems like we should just move on and stop dwelling on an event that happened over 40 years ago.


Texas Tour – Arlington

Wednesday, August 13th, 2002

The Ballpark at Arlington

The Ballpark at Arlington

I met my friend Marc at his house and we headed off to the game. This game is kind of a milestone in my quest to visit every major league ball park. It will be my 20th team. Just ten more to go (barring expansion or contraction).

The Ranger’s stadium has the rather ordinary name of The Ballpark At Arlington. Arlington is a town just outside of Dallas/Ft. Worth. We parked in the parking lot and walked to the stadium. From the parking lot is a great view of this brand new stadium. It is another of the trend to create new stadium with all the modern conveniences, but with that classic traditional baseball feeling.

Nolan Ryan

Nolan Ryan

The stadium was pretty nice. We walked the grounds. One of the most interesting attractions to me was the Nolan Ryan statue in stands behind center field. Nolan Ryan is one of the greatest pitchers in baseball history and his stats engraved in a circle around the statue drove home the point. He is the all-time leader in strikeouts, no-hitters ( 7! ) and a couple of other stats. Opposing players would take the day off so they wouldn’t have to face him at the plate. He also holds the record for the fastest pitch ever at 104 MPH.

The game wasn’t particularly interesting. The Rangers were getting blown out by the Chicago White Sox. Marc and I had a good time reminiscing about our high school days and I enjoyed some catfish and chips for dinner. All in all a good time, but I was very much looking forward to heading home the next day.



August 8th – August 14th, 2002

Thurday morning I drove up to Dallas. It took about 4 hours and I checked into another extended stay motel. Originally I had planned to stay in Dallas for a week, just like in Austin, but my Austin experience changed my plans. I was going to leave on the 14th, after the baseball game.

Again, the idea was the same. To just be there and experience Dallas. However, there were a few things I wanted to do. There’s an Apple Store in Plano, a town just north of Dallas. Apple has been opening stores all over the country, but none yet in Utah, so I had to go check it out. Also, I wanted to check out downtown and see some JFK stuff, and of course the Texas Rangers are in nearby Arlington.

The Apple Store

The Apple Store

Also, I have an old high school friend who now lives in Dallas. Marc moved to Georgia after he graduated from college and then to Dallas, where he works for Texas Instruments. I got in touch with him and had lunch with him on Friday. It didn’t take long for us to get back in the swing. Didn’t feel like we had been apart much at all. He took me to see TI’s digital projector demos where we watched the Star Wars: Episode II trailer on a big movie size HDTV screen with a digital projector. He invited me to his place on Sunday for dinner, where I met his family and ate a delicious meal. Marc and his wife, Christy, have 4 kids. 3 girls and 1 boy. The oldest is nine, so they have there hands full. It was nice to see everybody and to see how things are going.