Sometimes you see something so obvious, yet totally original that just seems like the "proper" way of doing it. The latest case for me was in atebits' Tweetie 2 for iPhone. The tab bar has a tiny arrow that animates to indicate the currently selected tab item. In addition to a custom, yet standard indication by turning the icon blue-ish this small animation just makes it even more clear to the user where they are.

So in the tradition of stealing great ideas I tried to find out how to do this. Queue Picasso quote here. Anyways, turns out it was fairly simple - it came down to:

  1. creating a view to contain a TabBarController and be its delegate
  2. adding an indicator image to the TabBarController's tab bar
  3. animating the image to the selected tab bar index when the TabBarController's didSelectViewController method is fired

I created a small Xcode project (following the NIB-less way) that shows how I cloned it. You can see it in action below:

You can download the Xcode project here. Next up is the pull-down to reload mechanism :)

Posted
AuthorPaulo Fierro

After doing this whole iPhone development thing for a little over a year now I've realized that I hardly ever use Interface Builder. Sometimes I'll create a dummy NIB, drag in some control and use the panels to find what certain things are called which makes it easier to search through help. But otherwise I simply don't use it, kind of like in Dreamweaver or FlexBuilder where I never use the Design view - eventually you start to render this stuff in your head.

Which I suppose is a little scary.

Anyways, another thing I found was that I never really grokked the whole Interface Builder way of dragging outlets back and forth - I'd often drag something wrong and the whole project would just stop working. Finding out what had gone wrong wasn't always the easiest thing in the world.

So I decided to figure out exactly how I could go about avoiding using Interface Builder at all. You can create your own custom UIViewControllers etc, using nothing but code which is a nice start - and, maybe its subjective, but I do feel like they run faster. Maybe its just me.

But the problem was MainWindow.xib. The default NIB, how do I get rid of it? I wanted pure non-NIB based project which may sound silly but hey.

Eventually I found out there are three things you need to do:

  1. Delete MainWindow.xib from the project and send it to Trash. Easy enough
  2. In your project's Resources group, find the Info.plist file remove the entry for "Main nib file base name". Delete the line and save the file
  3. In the Other Sources group, find main.m and modify the following line:
int retVal = UIApplicationMain(argc, argv, nil, nil);

Change this to

int retVal = UIApplicationMain(argc, argv, nil, @"PROJECTAppDelegate");

So if your project is called Cheese, it would be @"CheeseAppDelegate".

Now the project is NIB-less, but because the window is no longer being created in MainWindow.xib we have to do this in code, but its simple enough. In the AppDelegate.m file applicationDidFinishLaunching might look like this:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}

Just add the following line before hand to create it:

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

For me at least I now feel like I have full-control over what's going on in the project and I sleep better at night. It kinda feels like during a pure AS3 project.

Maybe its completely silly but I'll find out in time :)

Posted
AuthorPaulo Fierro

Great quote from an Art of the Title Sequence interview with Jim Capobianco on the end credits of Wall-E:

Always move.

Don't sit around waiting for approval or something to happen. I have found there is always something to do on your project. Even if it is the smallest thing it keeps the momentum going and momentum is everything. By always moving it gets you that much closer to getting the project done and you stay ahead of the people who feel it is there job to judge and can put a stop to what you are trying to say before you've had a chance to say it.

Like a shark keep moving or die.

How very true.

Posted
AuthorPaulo Fierro