I have been working away on my application for the past couple weeks, and by working I mean banging my head against a keyboard hoping it would do what I would need it to do. Fortunately, today I had another breakthrough, albeit a minor one.
The best analogy I could use to explain it to people is that I am a child, learning a new language, and always learning more about the world, but I lack the necessary words to communicate. The analogy stands in that I am constantly understanding how the code should work, but having the right code is another matter. Oh well, here’s what I’ve been doing.
I initially thought I’d be able to make a simple application for my work that was based on an existing paper marketing tool we had. little did I know it wasn’t going to be so easy. At first I thought of including a lot of functionality, but as I worked through it, it made less sense adding all this functionality that wasn’t available in the paper copy. In a moment of clarity, I realized, that I had reduced my scope, but also increased my effectiveness, and had decided, I needed only 6 or 7 screens to achieve everything I needed.
I was going to be working from a “home” screen with buttons that would lead to other pages. SImilar to a website. The majority of my experience came from building websites, so it made sense to me. As I went to code, I knew I needed to work with the ViewControllers and I knew I wanted a tabBarController. So, I started to code a tabBarController program, based on what I had done in the book. I got my two tabs working nicely. Then I tried adding a button to load a new page, and I got nothing but errors.
So, you’d expect that my breakthrough would be that I got it working, right? Well, that didn’t happen. What happened is a little perplexing for myself even.
I decided to add a navigation bar to one of the tabs, in fact, the same tab as I was having trouble with the buttons. Why? Well, in the Apple documentation about Tab Controllers, it is bundled with Navigation controllers. Truth be told, i don’t understand how to take what’s there and make it into code, but at least it explained that they are all sort of tied together in some ways. I assumed, if I could get the navigation controller working, I’m bound to get the buttons working.
After another 2 nights of googling and failing at Xcode, I was extremely defeated, but cautiously optimistic. I was starting to understand more and more that I needed to establish my RootView and then setup alternative ViewControllers, I just lacked the understand how to do it.
Now, during this time, I did download some sample code from Apple and some other book’s sample code for doing this sort of stuff, but they used Interface Builder, and I was trying to avoid that. While I really like IB, and I plan to use it ontText labels and buttons, I’d prefer to do as much programmtically as I can, including my navigation. So, those files helped me understand the need to setup ViewControllers, but nothing about how to do it programmatically.
Then today I stumbled across a Great link at the iPhone SDK forums that explained exactly what I was trying to do. I made a quick edit to my App Delegate, and voila — A navigation controller inside the first tab! Thank you DevTeamOfOne!
Now, the problem is the Tab Bar item name isn’t coming up anymore…. But, that’s for another day! Tonight, I savour the victory of my navigation bar, the xib file showing up properly and no crashes. Huzzah!
Another exciting post at Whitaker Blackall via iDevBlogADay about a musician who’s getting in the development game. I’m impressed in what he’s been able to do in 6 months. I think I’ve been at this for 3 months and I can just barely get view controllers going, and this guy is building games.