Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tutorials

Reply
 
LinkBack Thread Tools Display Modes
Old 11-30-2008, 07:14 PM   #1 (permalink)
New User
 
jamesbrannan's Avatar
 
Join Date: Aug 2008
Location: Gaithersburg, MD
Posts: 178
jamesbrannan is on a distinguished road
Default UINavigationController tutorial w/ multiple xibs and data sharing

A beginner's tutorial on the UINavigationController. Uses Interface Builder. Has multiple xibs. Shares data between xibs.

You can watch/download the hi-def version on vimeo. To download I believe you must be a vimeo member (it's free), and they hide the link down on the bottom right corner of the page. You can watch the hi-def version directly on vimeo. Here's the low-def version embedded (but probably too low def to be useful).



iPhone UINavigationController Tutorial Part 1 of 2 from James A. Brannan on Vimeo.

And,


UINavigationController Tutorial - Part 2 of 2 from James A. Brannan on Vimeo.

BTW.... Buy my book when it comes out in the Fall of 2009

Last edited by jamesbrannan; 11-30-2008 at 07:16 PM.
jamesbrannan is offline   Reply With Quote
Old 12-02-2008, 09:46 AM   #2 (permalink)
New User
 
jamesbrannan's Avatar
 
Join Date: Aug 2008
Location: Gaithersburg, MD
Posts: 178
jamesbrannan is on a distinguished road
Default

Comments, criticisms? I'm particularly interested in criticisms (other than production aspects, as it is free)....surely I did something poorly.
jamesbrannan is offline   Reply With Quote
Old 12-06-2008, 05:02 PM   #3 (permalink)
New Member
 
Join Date: Aug 2008
Location: Northern Virginia
Posts: 1
mlkeller is on a distinguished road
Default

Thanks again for the tutorial, quite helpful. Quick question - using this method with IB, how would you add a button to open a third level screen (e.g., on the details screen, adding a button to the navigation bar to navigate to a sub-details screen)?
mlkeller is offline   Reply With Quote
Old 01-14-2009, 08:59 PM   #4 (permalink)
New User
 
jamesbrannan's Avatar
 
Join Date: Aug 2008
Location: Gaithersburg, MD
Posts: 178
jamesbrannan is on a distinguished road
Default

BTW....I totally glossed over/missed making a connection to an IBOutlet in this tutorial. You will get a blank screen unless you make the connection in interface builder.
jamesbrannan is offline   Reply With Quote
Old 01-15-2009, 04:02 PM   #5 (permalink)
Tutorial Author
 
Join Date: Jan 2009
Posts: 144
meowmix23F is on a distinguished road
Default

Hi. I just finished your tutorial. I've been programming for a while. Now, here's my question: Would you reccomend sharing data through the app delegate, or can i just use NSUserDefaults?
meowmix23F is offline   Reply With Quote
Old 02-15-2009, 04:24 AM   #6 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 57
Coaster is on a distinguished road
Default

ahh, this is killing me, i been stuck on this for 3 days now.

Im trying to modify this and the other Tutorial about Multiple xibs to suit my app, but for the life of me im totally missing something.

I am making a quoting app for my work, and have to get values from multiple text fields, from multiple views, and use that info in other views.

Do i centralize all the data in the app delegate, or create a sharedData file like in this tutorial, and then access it from there as needed?

Alot of the data will be job prices ect, entered manualy and adjusted until ready to save to a sqlite database, but i need a temp file to access it.

The way my brain comprehends this is something like this:

xib1 -->
xib2 --> AppDelegate --> SharedDataFile --> AppDelegate --> xib4,xib3 ect
xib3 -->


Am i far off the mark here?

Nevermind, i wen though ns defults, all good,

PS thanks for the great tutorial, you guys rock!!, even a simple panel beater like myself can get a app working with the great info you guys provide

Last edited by Coaster; 02-20-2009 at 02:01 AM.
Coaster is offline   Reply With Quote
Old 02-16-2009, 06:03 AM   #7 (permalink)
Asa
New Member
 
Join Date: Feb 2009
Location: Bangkok, Thailand
Posts: 45
Asa is on a distinguished road
Default

Thanks James..
Asa is offline   Reply With Quote
Old 02-18-2009, 09:28 AM   #8 (permalink)
CTO Malus Pumila, LLC
 
Join Date: Feb 2009
Location: Michigan
Posts: 52
myemailisjustin is on a distinguished road
Default launching a view inside a .xib file from a UINavigationItem

Thanks for the good starters on this new platform, it's been very helpful. I have run into one problem that I'm trying to figure out, and I think for those that have actually got an entire application working, this may be a stupid question.

I've got a MainWindow.xib, which contains the "HomeView" Window and a TabBarController with one UITabBar and 4 UITabBarItem on that. When the program loads, the MainWindow.xib is unpacked and displays the HomeView Window and the TabBar at the bottom. When you select the second button on the TabBar, it loads the SecondView.xib file, which has its File's Owner set to a custom class named 'SecondViewController'. The SecondView.xib file contains a View, Label & UINavigationBar at the top. The UINavigationBar contains one UINavigationItem, set to "Add" --> so it displays the Plus symbol from the SDK. So far the interface was built using IB and the switching of the "views" via the TabBar works great.

So then I defined a method inside the SecondViewController.h & .m to handle the interface when the Plus button is pushed. I get it to launch that method, by wiring up the Plus button to the 'addEntry' method I defined in the SecondViewController.h&.m files. Now what I need to do at this point, is launch a new 'AddEntry.xib' file I have which contains another view with some fields on it, that I will be able to enter text into. When i click done, obviously the data would be saved to a .sqlite datbase - that part I've got down. What I'm missing is how to actually launch the view that is embedded inside the 'AddEntry.xib' file so that new view shows up when you click the add button on the navigation bar at the top.

I'm new to the whole concept of iphone development and this hole in my knowledge is not helping me complete the basics of an appication. I've watched many tutorials, but something is missing alright, and I don't know how to make that final connection from the 'addEntry' method defined in the SecondViewController files, and get that method to display the view embedded inside the AddEntry.xib file.

Can someone shed some light on this? Thanks in advance!
myemailisjustin is offline   Reply With Quote
Old 02-18-2009, 12:28 PM   #9 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 6
bullale is on a distinguished road
Default

Hi Justin,
I'm fairly new to this thing too but I think I might be able to help. I'm trying to explain this from memory so pardon the sparse use of correct terminology.

You can try making AddEntryViewController class files. Make sure the .xib file's owner is of this class. Then in your applicationDelegate, or whichever controller is handling views at the moment (perhaps your second view controller), you can create your view using:
AddEntryViewController *addEntryView = [[AddEntryViewController alloc] initWithNib etc etc];

Then remove your current view from the super view,
then add the new view (addEntryView) as a subview of the superview,
then release addEntryView.

Good luck.
bullale is offline   Reply With Quote
Old 02-20-2009, 03:48 PM   #10 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 6
bullale is on a distinguished road
Default

Sorry, I think I made a mistake.
Upon rereading what you wrote, I think there are several ways that you can handle this.
The first is to create multiple full-screen views within the SecondView.xib file. You can then hide your addView until it is needed. This is not the most efficient for memory usage but it sounds like this won't be a problem for your application.

The second is to make a new .xib file as you suggested. You will then need to remove SecondView from the window, and then add AddView to the window. You can have this handled in your application delegate. Check out Nick Myers' downloadable source code in the thread for his multiple .xib tutorial.Here

Third, you can create all your views programmatically and then control adding them and removing them from your windows or views as needed, and not have to worry about loading and retaining a xib into memory when it won't be used. An added benefit of using this method is that you would be able to control the views associated with your SecondView in a viewController and not have to clutter your application delegate. The downside to this is that it takes a lot more coding.

Finally, you can merge the second and the third methods. You can load the SecondView.xib and then programmatically add and remove an addView as needed. This has the drawback of keeping the SecondView.xib in memory when it isn't being used, but it has the advantage of allowing you to control all of your views associated with SecondView in its view controller, and not in the application delegate.

I hope that was clearer than the last time.

Last edited by bullale; 02-20-2009 at 03:52 PM.
bullale is offline   Reply With Quote
Old 03-01-2009, 06:43 PM   #11 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 184
VMan is on a distinguished road
Default Terrific videos!

Thank you so much for the videos. I have been painfully rereading Apple's docs, and my three Cocoa books trying to use IB with separate XIB files for my code. I wish I had discovered your videos earlier!

If you ever have the motivation to do another video tutorial, I think many would appreciate a video that shows how one can use IB to make a tab bar controlling separate navigation views, with at least one of those navigation views having a view that contains a small table view and some other graphical element. (For some reason, it was easy for me to have a tab bar with a table view that took the whole screen, but when I wanted to drag a table view to a VIEW to add other elements like buttons, it seemed considerably harder to wire it all together with separate XIB files.)

Thanks again!
VMan is offline   Reply With Quote
Old 03-09-2009, 04:12 PM   #12 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
Join Date: Mar 2009
Posts: 292
odysseus31173 is on a distinguished road
Default

I have seen your videos on vimeo before, but good to know that your on here now. Thanks for the tutorials.
odysseus31173 is offline   Reply With Quote
Old 03-09-2009, 04:40 PM   #13 (permalink)
New Member
 
Join Date: Feb 2009
Location: Sweden
Posts: 1
Signar is on a distinguished road
Default

Great stuff James!
Just wondering if the Interface builder will make me learn thing fast at the beginning and later show that I haven´t actually learned any Obj C at all. Hmm anyone who has switched from code to James approach? Or vice verse?
Signar is offline   Reply With Quote
Old 03-16-2009, 05:03 PM   #14 (permalink)
New Member
 
StickyTape's Avatar
 
Join Date: Oct 2008
Location: England
Posts: 45
StickyTape is on a distinguished road
Default

Has anyone got the source code for this tutorial they would like to share?
__________________
Twitter
StickyTape is offline   Reply With Quote
Old 03-17-2009, 12:07 PM   #15 (permalink)
New Member
 
Join Date: Mar 2009
Posts: 2
squidbot is on a distinguished road
Default

Quote:
Originally Posted by StickyTape View Post
Has anyone got the source code for this tutorial they would like to share?
Here you go, covers both videos.
Attached Files
File Type: zip NavigationTutorial.zip (18.9 KB, 625 views)
squidbot is offline   Reply With Quote
Old 03-17-2009, 02:43 PM   #16 (permalink)
New Member
 
StickyTape's Avatar
 
Join Date: Oct 2008
Location: England
Posts: 45
StickyTape is on a distinguished road
Default

Quote:
Originally Posted by squidbot View Post
Here you go, covers both videos.
Thanks squidbot! I find it a lot easier learning from code than videos
__________________
Twitter
StickyTape is offline   Reply With Quote
Old 03-23-2009, 12:58 AM   #17 (permalink)
New Member
 
Join Date: Mar 2009
Posts: 2
squidbot is on a distinguished road
Default

Quote:
Originally Posted by StickyTape View Post
Thanks squidbot! I find it a lot easier learning from code than videos
You know, generally I'm with you, but one of the problems I've had learning iPhone development is how to leverage Interface Builder to greater extent. I'd have never figured out how to set up a navigation controller, root view in a separate xib and navigation items correctly in IB without watching the videos. I've been doing everything in code up to now, and this video really illuminated how much code I save by learning how to use IB. Anyway, I guess this is a thanks to the original video author, this video has taught me more than all the documentation on IB I've read so far!
squidbot is offline   Reply With Quote
Old 03-24-2009, 06:46 PM   #18 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Montreal, Canada
Posts: 80
jfmartin67 is on a distinguished road
Unhappy Comments...

Quote:
Originally Posted by jamesbrannan View Post
Comments, criticisms? I'm particularly interested in criticisms (other than production aspects, as it is free)....surely I did something poorly.
Well, just finished viewing the first part of this tutorial... Technically, the screen quality is not quite there... a little bit too small... But also, we see what you are doing but it seems there is not enough explanation on why you do what you do... How the actions you do in IB relates to the actual UI and obj-c code...
__________________
_____________________________________________
Becoming an iPhone apps developer, one line of code at a time.
My Application: Ultimate Password Manager - A complete password manager integrated with a password generator

Building iPhone Apps Blog
jfmartin67 is offline   Reply With Quote
Old 03-24-2009, 07:23 PM   #19 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Montreal, Canada
Posts: 80
jfmartin67 is on a distinguished road
Default

Well, the second part of this tutorial is better technically (better screen resolution, better sound, etc.) On the content sidem it's ok but still missing some information for newbie like me...
__________________
_____________________________________________
Becoming an iPhone apps developer, one line of code at a time.
My Application: Ultimate Password Manager - A complete password manager integrated with a password generator

Building iPhone Apps Blog
jfmartin67 is offline   Reply With Quote
Old 03-31-2009, 01:52 PM   #20 (permalink)
New Member
 
Join Date: Mar 2009
Posts: 31
beggs5 is on a distinguished road
Default NavigationController to a Round Rect Button

Quote:
Originally Posted by jamesbrannan View Post
Comments, criticisms? I'm particularly interested in criticisms (other than production aspects, as it is free)....surely I did something poorly.
Great tutorial James. Can you tell me how to instead of the NavItem Button directing the control of the view change to have a Round Rect Button do the same thing? I'm rather new at this so if you do have help for me please tell me exactly where I need to change and/or modify the code. Thanks.
beggs5 is offline   Reply With Quote
Old 04-07-2009, 02:13 PM   #21 (permalink)
New Member
 
Join Date: Mar 2009
Posts: 11
Soal is on a distinguished road
Default

Quote:
Originally Posted by beggs5 View Post
Great tutorial James. Can you tell me how to instead of the NavItem Button directing the control of the view change to have a Round Rect Button do the same thing? I'm rather new at this so if you do have help for me please tell me exactly where I need to change and/or modify the code. Thanks.
Hi, I am new to iPhone dev. I am creating an application which load the first view with two buttons, clicking on one button direct you to the second view xib file which has the navigation bar with back button, and a search bar. clicking on search bar will lead us to another view which contains the search results.

my question is although I dont need navigation bar in the first view (view with only two regular buttons) should I set it as the root view controller for navigation controller?
Soal is offline   Reply With Quote
Old 05-17-2009, 03:41 PM   #22 (permalink)
New Member
 
Join Date: May 2009
Posts: 4
swiftmarval is on a distinguished road
Default

thanks i plan on developing something similar using this method
swiftmarval is offline   Reply With Quote
Old 06-29-2009, 09:18 PM   #23 (permalink)
New Member
 
Join Date: Jun 2009
Posts: 6
pmDavid is on a distinguished road
Default correct data sharing method?

Hi,

I watched the videos and found that they really helped me make sense of what I was trying to do.

At one point, James mentions that he's not sharing data between the xib's the 'correct' way... but doesn't elaborate. So, my question is, what *is* the correct way to do it?

In my app, I'm switching views similar to the example, but I have a table on my secondary view. I want to select something in the table, and have that selected value show up back on my first xib.

Right now, since I was trying to avoid what James did in the tutorial, was use my reference to my second view controller, and just get the value from the NSArray I have backing the table.

Any tips would be great ,
thanks!
pmDavid is offline   Reply With Quote
Old 06-29-2009, 11:12 PM   #24 (permalink)
New User
 
jamesbrannan's Avatar
 
Join Date: Aug 2008
Location: Gaithersburg, MD
Posts: 178
jamesbrannan is on a distinguished road
Default

Quote:
Originally Posted by pmDavid View Post
Hi,

I watched the videos and found that they really helped me make sense of what I was trying to do.

At one point, James mentions that he's not sharing data between the xib's the 'correct' way... but doesn't elaborate. So, my question is, what *is* the correct way to do it?

In my app, I'm switching views similar to the example, but I have a table on my secondary view. I want to select something in the table, and have that selected value show up back on my first xib.

Right now, since I was trying to avoid what James did in the tutorial, was use my reference to my second view controller, and just get the value from the NSArray I have backing the table.

Any tips would be great ,
thanks!
Realize these videos are *way* old...

The "correct way" I'm afraid is exactly like you would do it in your day job - if your a programmer - or how Stanford presents it. Basically, you don't want your application delegate to be tied to any one view. Moreover, you don't wanna junk up your delegate. The "correct" way, IMHO is exactly like Stanford says to do it, individual view controllers are responsible for its data, if it shares data with other view controllers, simply set the other controller's variables. It's a pain in the butt, but it keeps data more cleanly separated. Hopefully I'll have some time to do another tutorial. BTW, check out my latest tutorials on Vimeo. They don't have sound because they match written steps in my book, but I share data the "correct" way.
jamesbrannan is offline   Reply With Quote
Old 06-29-2009, 11:15 PM   #25 (permalink)
New User
 
jamesbrannan's Avatar
 
Join Date: Aug 2008
Location: Gaithersburg, MD
Posts: 178
jamesbrannan is on a distinguished road
Default

Quote:
Originally Posted by jamesbrannan View Post
Realize these videos are *way* old...

The "correct way" I'm afraid is exactly like you would do it in your day job - if your a programmer - or how Stanford presents it. Basically, you don't want your application delegate to be tied to any one view. Moreover, you don't wanna junk up your delegate. The "correct" way, IMHO is exactly like Stanford says to do it, individual view controllers are responsible for its data, if it shares data with other view controllers, simply set the other controller's variables. It's a pain in the butt, but it keeps data more cleanly separated. Hopefully I'll have some time to do another tutorial. BTW, check out my latest tutorials on Vimeo. They don't have sound because they match written steps in my book, but I share data the "correct" way.
BTW...this tutorial is outdated now that 3.0 is out
jamesbrannan is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 473
15 members and 458 guests
alexeir, David-T, Dj_kades, foslock, HemiMG, iAppDeveloper, jeroenkeij, LunarMoon, Mijator, Pauluz85, pipposanta, QuantumDoja, robsmy, sacha1996, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,928
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:23 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0