Tab bars and Navigation bars together

By Elisabeth Robson
June 24, 2009 | Comments: 95


The TableView is a common way to display data on an iPhone. For example, news apps like Wall Street Journal, New York Times and Huffington Post all use a table view to display a list of stories. When you click on one of those stories, you see the full news story in a detail view. At the top of these apps, you see a navigation bar that allows you to navigate back to the list of stories, and at the bottom, a tab bar that lets you select among different app functions or topics, for example.

Combining a tab bar with a table view and navigation bar isn't very difficult, but it took me forever to figure out how to do it properly. I found the explanation of how to combine tab bars and navigation bars on Apple's website woefully inadequate. I spent some time studying one of the examples that comes with the Apple documentation for Tab Bar Controllers, called TheElements, which builds this kind of app programmatically. After studying that for a while, it started to make more sense, but I really wanted to figure out how to do it using Interface Builder. I posted a couple of questions to the cocoadev mailing list, and got some really helpful answers and was eventually able to figure it out.

I've created an example to demonstrate how to build this kind of app and recorded a screencast partly so I'd never forget again, and also to help anyone else out there who might be struggling with this same challenge. There are lots of little steps that you have to do in just the right order to get it all working. A screencast seemed like the perfect way to demonstrate these steps since a lot of the work happens in Interface Builder and it's much easier to show what actions to take than it is to describe them in text or even with pictures.

If you try to build this app yourself by following the screencast, I'd love to hear how it goes and if the screencast was helpful for you. And if you have any feedback on the process I'm using to build this app, I'd love to hear that too.

Or, to follow along more closely with the code, Click here to view or download the original high resolution .mov file. [254 Mb]

Update: Here's the downloadable code sample

Visit Part II: O'Reilly Books Example updated: Show a different image for each book


You might also be interested in:

95 Comments

Doing the same project in code, no IB, is left as an execise for the reader, right?

I'm not sure why this would be hard, since it's explained quite clearly in the View Controllers document.

http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/

It's actually easier.
After having your TabBarController, set the required view controller's class to navigation controller, and just drag a generic table view controller directly on the tab bar controller window and you're done.

is the finished code available somewhere?

-bowerbird

Alex: Thanks, I'll give that a try!

Ash: Can you point to the precise page where Apple describes this?

Rudifa: Yes :-) Also, check out TheElements code that you can download from Apple as an example.

Bowerbird: no, but I'll see if I can make that happen

Got a couple of hints from Joe Heck on this app:

I don't need to explicitly identify the datasource and delegate protocols in BooksTableViewController; that comes by subclassing UITableViewController (just a small change, but worth noting).

Also: I don't need the BooksNavController class. I don't actually use it for anything, so I could have created a generic navigation controller without subclassing it, and used the navigationController property in the BooksTableViewController to access it (so I don't need to explicitly create the class and a reference to it in the table view controller). This means I can replace the lines (in BooksTableViewController):

ORBooksAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.booksNavController pushViewController:bookDetailViewController animated:YES];

with just:

[self.navigationController pushViewController:bookDetailViewController animated:YES];

A bit simpler and probably better coding style.

Thanks Joe.

you wrote:
> Also: I don't need the BooksNavController class. I don't actually use it for anything, so I could have created a generic navigation controller without subclassing it...

I wish I understood this better. Will you ever change your source code provided, to reflect this change? Thank you, it's a great tutorial..

AWESOME tutorial! Thank you sooooooo much!

I followed your tutorial and have my app working correctly. My next step however is that I'd like for when the user selects each row they are taken to a separate view. Currently with your tutorial you have all the clickable rows going to the same view.

Do you have a tutorial for this?

Thanks again!!!!

I guess what I mean is I'd like to parse an XML file and the data that's loaded into a view is determined by the row that's clicked. I'm just completely stumped on this...

A huge help in getting started building a UI with IB - thank you!

Great tutorial! Now what if I want to allow the individual rows in the UITableView to be clicked so they are each pushed to a new view (with its own data)?

I realize this is the section of your code to work with (and I believe another controller and its xib must be built per row):
------------------------
NSInteger row = [indexPath row];
if (self.bookDetailViewController == nil) {
BookDetailViewController *aBookDetail = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:nil];
self.bookDetailViewController = aBookDetail;
[aBookDetail release];
}
bookDetailViewController.title = [NSString stringWithFormat:@"%@", [booksArray objectAtIndex:row]];

[self.navigationController pushViewController:bookDetailViewController animated:YES];
-----------------------------

How would I go about doing this?

John,
I've posted a new screencast that I hope answers your question.

Elisabeth

Thanks Elisabeth for this great tutorial!

Amazing tutorial thanks so much! I was struggling on exactly this issue and found your vidcast on Google. It was a lifesaver. Thanks much!

Jon,
So glad it was helpful!
Elisabeth

Hi Beth,

Thanks, this was a really useful walk through. Your comments as you coded really solidified my newly learnt thinking about iPhone app development and your tutorial was much more on my level, versus the documentation. Thanks very much !

Ben

Thank you for an amazing tutorial....

Been struggling with that for a while :)

The best voice for an iphone app tutorial i have heard so far also

Good work :)

Love the latest tutorial. Thanks a ton. Now if I wanted to show info. like name, address and phone number on the detail view (instead of an image) how would I go about altering the code to do that?

Cheers!

Brian, You would need to create a view with places to put the data (e.g. a "contact" view), and in the method where you are pushing the view on the stack, you would set a property in the view controller for the "contact" view with a pointer to an object that is holding that data. Then in the viewWillAppear method in the "contact" view, you would set the values of your labels or text fields for the view with the appropriate data. Hope that makes sense! Will be a good topic for a follow up screencast when I have more time :-)

Thank you so much for this Tutorial. I'm new in iPhone Development and it takes days to trying implementing this. After watching your Tutorial its so easy.

Thanks again.

Elisabeth,

I spent the whole day trying to put a navigation bar inside a tab bar controller. And when I decided to search for help, you appeared on the first page. You saved my day. Everything worked perfectly.

Thanks!

Joao

This definitely save me a great deal of time. I was combining a Tableview with navigation bar with the a Tab bar... your tutorial was great. thanks. Chuck

Thanks for exactly the right approach. It got me past a sticking point.

When I went past this tutorial to push other view controllers onto the nav stack, I got messed up by a typo in Apple's commented code (which leaves out "animated: YES)" at the end of the push code, and leads to a cryptic error. Come on, Apple!

If Elisabeth could lead us through bringing in simple flat database files via SQLite to populate a table view without the elaborate Core Data code, I'd buy all her books!

That's just brilliant, thanks a lot.
It helps a lot to see you in action, and to get the repetitive stuff about releasing the properties or connecting the views in IB

thanks elisabeth! i was trying really hard to combine both tabbar and nav controller before i saw ur page but failed to do so. U reali saved me a lot of time. hugs.

Thanks Elizabeth for this wonderful tutorial. Most of the examples/tutorials on the net, explain each thing separately. I got burned trying to combine them in one app. Here I got exactly what I was looking for.... tabbar with nav bar with table view. Could not have asked for a better simpler tutorial!

I have a another issue now. I am following the same steps you mentioned in my project. I noticed that viewDidAppear in root TableViewController is not getting called when I go to the screen initially, or when returning back to the screen from child screen. I have put in break point and fail to see what I am doing wrong. However, I did notice that if I switch to another tab and then come back, everything works great, including viewDidAppear that gets called.

I did see this behavior in your sample app.

Any ideas???

p.s. This is driving me crazy. ;-


Peter.

Finally, I started retracing all my steps. I found out that my colleague had added a splash controller view to the main window instead of the root controller view. Once I changed this back to add root controller view to the main window, things started working just great.

Everything now works just as expected.

Very good tutorial on combining these controllers - Navigation and Tab Bar. Most iPhone development books that I've read so far handle them independently and then you're left with figuring how to incorporate both within the same app. Great job!!

Where was the vidcast on Google that explains how to set up different views for each cell/book when you click on the button?

Hi elizabeth yes must agree with everyone people like you don't know just how help you are. I spent ages creating a tabbarcontroller that has navigation controllers and table views using ib it took me a long while your explainations here actually clear up a lot of my misconceptions with how I did it. My biggest problem was with setting button on the navbar that can react with my code via the delegate but I think what you have said might cure it can't wait to try have you done any other vid cast? Be interested to view x

With help such as this tutorial, I successfully completed my first 3 apps, and am working on more. Thanks again to Beth for posting this.

In reviewing it, I am confused about your sizing of the view window when using the status bar, nav bar, and tab bar. As I understand it, these are 20, 44, and 49 pixels high, a total of 113 pixels of 480. That leaves 367 pixels, yet in the video you say to size the view as 346 pixels high. Why is that?

Beth, thanks a bunch for these Tutorials. They did help me kickstart my iphone knowledge. What an unfriendly developer environment! No wonder why the iphone is not getting any major corporate adoption. But my son loves it for video games !

Also wanted to mention that you have a beautiful voice. You should really come with more tutorials like these ones.

Thanks Elizabeth for the tutorial(s). Thanks to share your work. I can use now IB for this, very helpful.

I tried to add a "search display controller & search bar" following the TableSearch example from apple. But the structure is quite different. Can you give me a way to implement a search function ?

Hi Elizabeth,

Thanks for lovely explanation . I have a question " None of my pictures " Default.png" or two other images for button are getting displayed . Instead i am seeing just
black shadow . Please help .
Thanks

Vivek,
Thanks for your comment. Are you using single layer PNG files? Double check the file type.

Elisabeth

Thanks all for your comments, I'm slowly attempting to catch up and respond to you.

Nice tutorial. I need some help accessing navigation bar in this model. How do I change the color or title of navigation bar here ?

Hi Tebe,
Check out the reference on UINavigationController. You may need to assign a delegate (UINavigationControllerDelegate protocol) too.

Here's some good info on how to modify the navigation bar:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html

Elisabeth

Oh, and specifically for the title , you should be able to do self.title = @"..." in the viewDidLoad method in the Navigation Controller.

Elisabeth,
This is hands down the best iPhone tutorial on the web. You are really good at this and should consider doing an in depth series. I know books are your thing with O'Reilly, but honestly, books and newspapers are becoming a thing of the past. You have the chops to cross over so get your publisher to foot the bill and get cranking. I think you'll find there is a big market for it. Anyway, thanks so much, I learned alot!

Michael,
Thanks for your comment! I'm glad you found it helpful.

I actually *am* doing video :-) I just published a video course on iPhone web apps:

http://oreilly.com/catalog/0636920001515

I would like to do more videos on native app development, just need to find the time.

Cheers,
Elisabeth

As a matter of fact I found that link on my own shortly after I left you the message (thanks for the quick reply, just saw it today). I then promptly signed up for Safari Books online and had viewed the first 3 sections by 6AM the next morning! I had to work or I would have joined you online for the last installment. It seemed like forever before they posted it this past monday. In the meantime I got to compare your work to that of your peers on Safari Online (you're still the best :) ).

One of the viewers asked a question about the video link in the player app (it didn't make sense to you the way he had phrased it) and I think he was looking for a way to link to video stored on the phone as apposed to the website (faster load, less chance of breaking). The thought had crossed my mind as well.

I was wondering how I might do that. Is it possible to create a video resource like an icon in the resources folder? Perhaps, if I kept the vids separated amongst the other iTunes media and linked to them there, I could then make the content an add-on sale... How would these options change your url code?

MP

PS Please Go Native ASAP!

Please email your response so I know when you've had time to read the question...

Thanks,
MP

Thanks for the great tutorial! Best one I've seen so far!

Quick question: I'm trying to link the app delegate to the Tab Bar Controller, but I can't. I can only link to the tab bar itself. What am I doing wrong here? Because I know it's all my fault... :D

Thanks!

P.S.: I know I'm doing something wrong here because I try to build the app right after doing the "about" view, and it gives me an error in the .m file that "Request for member "view" in something not a structure or union." So I'm obviously failing to link something right...

Elizabeth, great video, many thanks for putting this together as you've saved me a lot of work. Its great to have people like you who are ready to share their knowledge and put in the effort to creating content like this.

Thanks again.

Nabeel

Excellent tutorial, but I can't for the life of me work out how to make each table row appear as a separate loaded XIB (Nib) file! If you read this Elizabeth, it would be great if you could extend the old tutorial to include making each view separate. Someone on the Tutorials YouTube page suggested using this code format, but I had no luck with this either. Must be missing something along the way
--------------------
if ( row == 0 ){
[delegate.reportsNavController pushViewController:amPmPieChar tViewController animated:YES];
} else if ( row == 1 ){
[delegate.reportsNavController pushViewController:perHourBarC hartViewController animated:YES];
}
-------------------------
Can anyone out there can give me step by step instructions? (based on Elizabeth's tutorials). As much detail as possible would be appreciated. This would make my app complete. Thanks if you can. John

Hi,

This is a bit long but necessarily so in order to explain correctly....

I have an app that comprises a Navigation Controller embedded inside a Tab Bar Controller. The combination of the Apple documentation, this thread and others has got me to the point where I can build and run the skeleton application. What I am now having problems with is the next step (and I can't find any tutorial that covers this). Let me explain in more detail.

In IB, I have the main objects set up as follows:
MyAppDelegate has outlets for MyNaviController and the main window:
-----------
@interface EarTrainer2AppDelegate : NSObject {
UIWindow *window;
UITabBarController *tabBarController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
-----------
The view controller for the Tab Bar Controller's main view is a custom controller as follows:
-----------
@interface ETITMainViewController : UIViewController {.........}
-----------
ETITMainViewController has been installed in IB and I can't show a screen shot of the xib file. There are four other view controllers installed in the Navigation Controller - when I build and run the application it correctly shows the view associated with ETITMainViewController and I can click on the tab bar to go to the other view controllers etc. The application content within ETITMainViewController all works fine. My problem is that I cannot hook ETITMainViewController to the containing Navigation Controller. More detail.

I have the Navigation Controller set to display a toolbar. Navigation Controller gets the contents for the toolbar from the view that is currently at the top of the stack. This means that ETITMainViewController has set its toolbarItems property to define the toolbar entries and that Navigation Controller queries ETITMainViewController for these items and displays them. This is all done behind the scenes. All fine and dandy. Works like a charm. In code in ETITMainViewController:viewDidLoad:
----------
.
.
[self setToolbarItems:[self createToolbarItems]];
.
.
----------
Now the problem starts. There is no linkage from the Navigation Controller to ETITMainViewController or vice versa so I can neither have Navigation Controller set an instance variable in ETITMainViewController to represent itself nor can I have ETITMainViewController reference Navigation Controller at run-time. Hence, I cannot have Navigation Controller respond to toolbar button touches and push a new view onto the stack. An example of the code creating one of the toolbar items in ETITMainViewController:viewDidLoad is as follows:
----------- (sorry about the poor formatting)
UIBarButtonItem *repeatItem = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"02-redo.png"] style:UIBarButtonItemStylePlain target:self action:@selector(handleToolbarEvent:)];
-----------
Notice the 'target:self' parameter. What I really want is 'target:[self myNaviController]'
Even if I have ETITMainViewController handle initial responses to toolbar button touches, I will want to forward those events to the Navi Controller to push/pop views on/off the stack.

So, after all this long-winded explanation, how the devil do I get to a situation where ETITMainViewController knows the identity of the Navi Controller? Final point to note is that since ETITMainViewController is loaded from a separate xib file, I cannot query up the superview chain beyond the root view in the xib file. Hence I cannot discover the identity of Navi Controller that way. Here is the debugger output:
-----------
(gdb) po [self view]
> (gdb) po [[self view] superview]
Cannot access memory at address 0x0
-----------
Any assistance would be verrry welcome as I am truly stuck.

Well,

you can forget my post above as I have fond a solution as follows:

- subclass UINavigationController and change the class of Navigation Controller in IB to be this new subclass. Create a toolbar handler entry point in this new class:
-------------
@interface ETITNavigationController : UINavigationController {

}

-(IBAction)handleToolbarEvent:(id)sender;
-------------
In ETITMainViewController, create an IBOutlet for the subclassed Navigation Controller. In IB, drag that outlet onto the Navigation Controller entry:
-------------
@interface ETITMainViewController : UIViewController {
....... other stuff
UINavigationController *naviController;
}
@property (nonatomic, retain) IBOutlet UINavigationController *naviController;
-------------
Now, ETITMainViewController can reference ETITNavigationController - the critical issue.... also modify the toolbar creation code to specify ETITNavigationController as the target for button touches (example for one of the buttons follows):
-------------
UIBarButtonItem *configItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"30x-Tools.png"] style:UIBarButtonItemStylePlain target:[self naviController] action:@selector(handleToolbarEvent:)];
-------------
And we're all done.....

i have built the above example successfully, but have now added another tab bar item that opens a viewcontroller as in a home page, and this works. I have added a button to the page that i want to be able to click and open the tableview that was part of the example. I am not sure how to do this, as my attempts have failed. Can someone please point me in the right direction. thanks

Thanks Elisabeth,
Good Tutorial for getting understanding of TabBar Controller with Navigation Controller.

I am looking to use User Data input in view which is interface with tab bar of Navigation Bar.

I have built Tab Bar Controller based application, Navigation Controller added with one tab bar interface.
I have attached nib file with that tab bar, in that I am tried to take user data inputs.
Here how to get UIresponder events in view implementation file ...means how to get control to textFieldShouldReturn function once first data entered in Text Field so cursor can got next data Text Field ?

Please give you suggestions?or any tutorial related to this?

Elisabeth,

Thanks so much for the video. I had created an application based on the flipview template and I wanted to created my flipside setup to be just like this but was running into all kinds of problems.

I've watched your video and have applied the lessons learned here to my application and am VERY happy to say that I'm all setup properly now.

You are a life saver. ok, my life wasn't really in danger, but I can now sleep stress-free.

woohoo!

Just Super!

Hello Ms.Robson,
Thanks for this tutorial.
Couple of doubts: The way this is set up, the first tab bar lists the names of the books and when the book is clicked, it takes the user to the next page with details about the book.
Now--the "book details go here"--is that the same page for all the books? Can we have a separate detail page for each book?
Also, what if I wanted another navigation on the details page--for example, the below if what I'm looking for:

Author ABC
Book 1
book details of book 1
Book 2
book details of book 2
Book 3
book details of book 3

Author XYZ
Book 1
book details of book 1
Book 2
book details of book 2
Book 3
book details of book 3

Author RST
Book 1
book details of book 1
Book 2
book details of book 2
Book 3
book details of book 3

So the first page would consist of all the authors--and when each is clicked, it'll take them to their respective pages with lists of books--each book with have its own page with book details.
All this will be in the TAB 'Books'...I might also need to have other tabs such as Music, Dance, etc...

Any help with this would be greatly appreciated!
Thanks.

What I'd recommend in this case is to have a two level table view, so you'd list the authors in the first level and the books in the second level.

Thank you very much Ms.Elisabeth Robson

Thank you for this useful tutorial. It's the only one that is easy to follow...unfortunately it doesn't work for me. I've checked the code four times comparing yours to mine but when I get to the cells and click on one of them the detail page does not come up. The app just exists. Any ideas? I am able to click on the tabs and go from one page to the other. The items come up in the table as well and I'm able to scroll up and down, it's just when I click on one of the items nothing happens. Thanks in advance for your time

Tim, check to make sure you are doing the right thing in the

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

method. You should be pushing the new view controller onto the navigation controller stack. Perhaps add some NSLog() calls here to make sure that method is being called correctly.

Thank you for this useful tutorial. It's the only one that is easy to follow...unfortunately it doesn't work for me. I've checked the code four times comparing yours to mine but when I get to the cells and click on one of them the detail page does not come up. The app just exists. Any ideas? I am able to click on the tabs and go from one page to the other. The items come up in the table as well and I'm able to scroll up and down, it's just when I click on one of the items nothing happens. Thanks in advance for your time

Thank you so much, Elizabth for your excellent tutorial.

I couldn't find any information on both tab bars and navigation bars until I found yours.

Your clarity in explaining these concepts really kept me going. I hope to have my first app out in a few weeks, and you were instrumental in me getting it together!

I just found your video last night. I'm new to iPhone and Objective-C development having spent most of my time with ASP.Net, SQL databases and ERP applications. The video helped me a lot in understanding the mix of tab bars and navigation in an app. It has similarities in what I'm trying to do with my apps.

I have another issue which might interest all newbies. This is basically a calculator that would enter numbers in view #1, do some math, and display the results in view number #.

1. From view #1, a user would enter several float values such as systolic BP, temperature, diastolic BP, etc.
2. When the user touches the 'compute' navigation button (in view #1), a calculation will be processed and display the results in view #2.

I don't know where to put the user entries if its in the app delegate or view #1 and how to save and pass these values so that view #1, app delegate, or view #2 can do the math operations then send the results to view #2.

Hopefully I explained well what I'm trying to accomplish and get the optimum way how to do this.

Ricky,
You would need to create an input screen with variables to hold all the values the user enters on that screen. Then you'd "pass" these values to the second view, by setting equivalent variables to those values in the second view before pushing the view on the stack.

I'd create separate view controllers for both views (rather than using the app delegate). If you make the values properties, you can easily set them before pushing the second view on the stack using the "dot notation" for properties.

I hope this helps!

Elisabeth, thanks so much for this tutorial; I'd really been struggling with this.

Liz.. this tutorial was amazing!! exactly what I was looking for.

Thanks a million. Keep up the great work.

Hey Elisabeth,

One question.. how would you add a button to the navigation bar? say, a 'compose' button that should appear on the top right corner of only specific views (e.g. in the top right corner of the 'About' view in your example).

Thanks a lot for this wonderful article and video. I am stuck at the place where you alter the height of the View to 411 pixels.. in my IB this is not editable. (The red lines are exactly as per the video, I also tried to edit the NIB via XML but still does not change)... Please help.. Thanks in advance.

Hi Sree,

I wrote my post below yours, not having read yours first. If you have a look at it, you should see the answer your looking for.

basically the solution is to choose 'aspect fit'

I don't know why we can't change the height and she could, but I imagine it has something to do with us using a newer version of the interface builder or something.

you'll probably also find that you'll get a few warnings further on in your tutorial, about 'depreceated' lines or something. this is just telling you that in this newer version, that the line is no longer the preferred or optimal form of that command.

Hi Elizabeth
Your tutorial was brilliant, it provided the step by step help I needed as a complete beginner, and I've got a far stronger understanding of what I'm doing now.

There was one particular part that had me stuck for a while.
In the tut you resize the 'View' each time by selecting the height and changing it.
when I did this tutorial, I could not for the life of me find out how to do that change, because for me, the height and width boxes etc.. were greyed out, I could not click on them and change them.

After a bit of playing about I found an alternative

I simply selected the View to be 'Aspect Fit'

not only did it mean I didn't have to physically calculate the height every view would need to be, I imagine it means the views are more adaptable to other changes, eg in the height of the tab bar.

(so if anyone else is stuck on this, I hope it helps)

thanks again Elisabeth

Thanks for the great tutorial. It also very useful for those who tries to learn English ;)

Thanks Elisabeth for this great tutorial!

hi i tried out your tutorial and its working fine.But ive got the problem that the tabbar view that i created is itself a drilled down view(navigated view; whatever).Now i cant navigate further into any of the tab views.(Eg:when i select a row in a table view it wont go to the next view.)These things where working fine whwn i worked out your tutorial as a standalone project.I guess its a problem with th navigation controller heirarchy.Any idea what i can do??

Very helpful.
Thanks :)

This is an awesome tutorial, Elisabeth! But unfortunately, after doing step by step this app, I can't see the details of any of the books when I click on them.
I have this horrible error (which appears in the console):

[Session started at 2010-11-03 23:20:05 +0000.]
2010-11-03 23:20:07.644 eMapKit[9852:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'BookDetailView''
*** Call stack at first throw:
(
0 CoreFoundation 0x02487b99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x025d740e objc_exception_throw + 47
2 CoreFoundation 0x02440238 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x024401aa +[NSException raise:format:] + 58
4 UIKit 0x004ae4f8 -[UINib instantiateWithOwner:options:] + 2024
5 UIKit 0x004afeb5 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
6 UIKit 0x0036595f -[UIViewController _loadViewFromNibNamed:bundle:] + 70
7 UIKit 0x00363675 -[UIViewController loadView] + 120
8 UIKit 0x0036354f -[UIViewController view] + 56
9 UIKit 0x003619f4 -[UIViewController contentScrollView] + 42
10 UIKit 0x003717e2 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
11 UIKit 0x0036fea3 -[UINavigationController _layoutViewController:] + 43
12 UIKit 0x00371067 -[UINavigationController _startTransition:fromViewController:toViewController:] + 326
13 UIKit 0x0036bccd -[UINavigationController _startDeferredTransitionIfNeeded] + 266
14 UIKit 0x00372d8b -[UINavigationController pushViewController:transition:forceImmediate:] + 876
15 UIKit 0x0036bb67 -[UINavigationController pushViewController:animated:] + 62
16 eMapKit 0x00002841 -[eBooksTableViewController tableView:didSelectRowAtIndexPath:] + 466
17 UIKit 0x0032ca48 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
18 UIKit 0x0032332e -[UITableView _userSelectRowAtIndexPath:] + 219
19 Foundation 0x0003821a __NSFireDelayedPerform + 441
20 CoreFoundation 0x02468f73 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
21 CoreFoundation 0x0246a5b4 __CFRunLoopDoTimer + 1364
22 CoreFoundation 0x023c6dd9 __CFRunLoopRun + 1817
23 CoreFoundation 0x023c6350 CFRunLoopRunSpecific + 208
24 CoreFoundation 0x023c6271 CFRunLoopRunInMode + 97
25 GraphicsServices 0x02d6600c GSEventRunModal + 217
26 GraphicsServices 0x02d660d1 GSEventRun + 115
27 UIKit 0x002c7af2 UIApplicationMain + 1160
28 eMapKit 0x00001f94 main + 102
29 eMapKit 0x00001f25 start + 53
30 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'

What can I do with this? because I have the same error with another project that I have to do for my job and I can´t continue because of that.

Thank you so much,
Elena.

I have checked the BookDetailView.xib, as the error message suggests.
The Class Identity of File's Owner is setted correctly.
And the xib is saved.
The view in the xib is connected to the view outlet of File's Owner.

What else can I check?

Thanks!

It looks like with the latest version of Xcode (3.2.4) it is not possible to create a UITableViewController subclass anymore.

Can you provide an updated version of this tutorial?

Thanks for the effort.

(ps, to change the size of the view to 411, it has to be a view without status bar. remove that from the attributes of the view and then you can change its size).

Hi,

I'm trying to do the step at 13:35 but it doesn't let me connect the BooksAppDelegate navcontroller to the BooksTableVIewController.

Any help?

i'm stuck on the EXACT same step. I have xcode 4 and it won't let me connect my app delegate to the "selected Books Nav Controller"... Please help!

Is there an updated tutorial with xcode 4?

Hi,

Thanks for the excellent tutorial. It really helped me understand how to combine the Tab Bar Controller and Table View Controllers.

Thanks Beth for the great tutorial. So much more clear than what Apple provides today and impressive for someone who was (at the time) only a few weeks into iOS development. I like to do as much as possible in IB - I have enough code to write - and the wiring required to implement both controllers was not intuitive.

Thanks for very helpful tutorial. I'm following the tutorial exactly.
Up to the first simulation of the tutorial, it works. But, I don't get any response when I press Build and Run for the second simulation of the tutorial. I tried several times, so I am quite sure I followed the tutorial exactly. Is there anybody who has done it successfully with Xcode 3.2/iOS 4.2 Lib environment? Any helpful comments?

Thanks for the great tutorial!
Everything was fine until I hit the line of code where you push the detail view controller. I get the following error:

Program received signal: EXC_BAD_ACCESS

Any ideas what might be the cause of this error?


Regards

Check your spelling when loading xib files in code, despite the simulator not noticing case mistakes, your real device will !!

ie tabview and xibs etc as mentioned above are not removed in the newer xcode versions, ie I'm using the latest and greatest build from apple + sdk, and no probs until I realised my own case sensitive mistake.

Excellent tutorial. Any chance you would be willing to redo it using Xcode 4? There are enough differences between 3 and 4 that it's devilishly hard to get everything working.

Evan,
Yes, I definitely need to update this tutorial! I just haven't had time yet, but will do it when I can.

I have posted your tutorial at my site:

http://www.xcode-tutorials.com

Hey,
I really love your video tutorial. I have a question and hope you can help me quick with my iPhone project as well. First off, I have a lot of data that I want to populate, and maybe I will use your code to populate, but I was wondering if there is a code to populate a Table View in the Tab Bar application with a .plist? Second, your video tutorial started on a Windows-Based project. I was wondering how do you start it on a Tab Bar application instead of a Windows-Based project? Because I started my project based on a Tab Bar application, and have almost completed it (I don't want to restart my project as a Windows-based), adding the Table View with Navigation controller in a Tab Bar Controller (just like your video tutorial on the book navigation tab bar), is the last part of my project. Like I don't want the code to start on my delegate files, I want them to start on one of my Tab Bar files.

So yes, sorry if this is too long, but I really hope you can help me with my last part of my project, thanks

I agree with Evan, it's definitely an awesome tutorial and it helped me a lot getting started. However it took me a while to figure out how to translate this to xcode 4.

I think, a _lot_ of people might get transcended into a state of utter blissdom, if you come up with an update.

Utterly grateful

Michael Kastner

Michael and others -
Thanks for your comments, I will do my best to do an update for Xcode 4 soon! I appreciate the feedback.

Elisabeth

One of the best online tutorials I have found but unfortunately I get stucked in xcode 4. I think I do everything right but I do not get the Navigation Bar under Books Nav Controller. But as I'm new to xcode and don't know the difference between 3 and 4 I must miss something. I would love an update of the tutorial I I think you should do more of them, you are great at it. Nice voice to listen to, and the speed is perfekt. I appreciate that you take the time to explain why to write code x and y.

Yes using Xcode 4 for this type of app is so different. I tried everything along the lines of your brilliant video in the end I had to use your source code to achieve it I find in this latest Xcode everything is so different will keep an eye for your updated video. I used your video for a previous project and it worked great.

Yes using Xcode 4 for this type of app is so different. I tried everything along the lines of your brilliant video in the end I had to use your source code to achieve it I find in this latest Xcode everything is so different will keep an eye for your updated video. I used your video for a previous project and it worked great.

I've just run through this with XCode 4 as a newbie - excellent tutorial - but a few slight hiccups along the way - for example creating the Nav Controller in the Tab Bar - found if you dragged the Nav Controller object into the Tab Bar Controller XCode 4 sets everything up for you.

Once I worked that out everything else went smoothly.

Thanks - been trying to do this for ages.

This tutorial saved me so much time. I read some info on the Internet that it was best to avoid interface builder to create a TabBarController -- NavigationBarController -- TableViewController app, but IB works just fine AFTER walking through this tutorial. THANKS!

I've got a problem using Xcode 4:

I used the code the way it is presented in the sample files:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSInteger row = [indexPath row];
if (self.bookDetailViewController == nil) {
BookDetailViewController *aBookDetail = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:nil];
self.bookDetailViewController = aBookDetail;
[aBookDetail release];
}
bookDetailViewController.title = [NSString stringWithFormat:@"%@", [booksArray objectAtIndex:row]];

[self.navigationController pushViewController:bookDetailViewController animated:YES];

Compiling works without a problem but when i click on an element of the tableview, i receive the error "Thread 1: Program received signal: "SIGABRT" " in the last line...

Help please... !!!

Thanks so much for the tutorial Beth, you've explained everything so clearly! I can't wait to see more of your videos.

Like a few people here I've struggled making the connections between xcode 3 and 4. One thing I'm really stuck on is how to add a UITableViewController subclass... this option seems to have disappeared in xcode 4!?! If you could maybe just explain how to work around this that would be great!!

News Topics

Recommended for You

Got a Question?