
iPhone Tutorial - Multiple XIB files
1 year ago
This is a detailed how-to that describes and demonstrates how to use multiple XIB files in an iPhone SDK project.
The source files for the tutorial can be downloaded from austinbull.com/tutorials/tutorial1.zip
The source files for the tutorial can be downloaded from austinbull.com/tutorials/tutorial1.zip
-
Vimeo: About / Blog / Developers / Jobs / Community Guidelines / Community Forums / Help Center / Site Map / Merchandise
/ Get Vimeo

Previous Week
Great video. :D
Can you make one tutorial for the table view?
Congratulations on your excelent video.
You can use one view controller to control two views, however that defeats the purpose of the tutorial which was how to use multiple XIB files.
I need some advice and maybe you could point me in the right direction .
I have a working app that parses a remote XML feed and stores Titles in a table view.
The app was written as a Navigation based app.
Accessing and parsing the XML can take some time, so rather than display an empty table view, I would like to display an image and a progress indicator until the table view has been primed.
I noticed that the Navigation based app has a MainWindow.xib, so I set this up with the image and progress indicator
The XML parsing and table view creation is done in the RootViewController
As the Application sits, now:
1) The application loads and displays the MainWindow image
2) According to the console trace the parsing is done and the Table View is primed
At this point I would like to switch to the (original) table view. I could add a button to the MainWindow view, but it would be smoother to display a progress indicator, then switch views when the parsing/priming is done.
Questions:
1) Is it good practice to use the MainWindow view for this or should I create another as you did in your example?
2) Based on the answer to 1):
a) where should I do the Parsing/priming
b) where should I control the progress indicator
c) where should I switch views
Whew!
This may sound a bit complex, but I think it is a very common challenge to anyone writing an iPhone app that primes a table view with dynamic data that is accessed over a cell communication link.
Finally, have you considered offering a NiPS (Noobie iPhone Programmer Service)?
I think there are a lot of people who would subscribe (pay for) a service that would assist them with writing iPhone apps. I know I would!
I am not asking you to write the app (I want to learn to do that)-- I just want periodic advice/guidance to prevent going off the path, or being able to ask questions when faced with a new (to me) device, programming language, SDK and development tools.
Any help will be greatly appreciated!
I do wish you would consider offering a NiPS service!
TIA
Dick Applebaum
As for parsing files, that all really depends on when and where the program will need the data. If you're building an app that needs the data from start to finish, then I would do the parsing either in the applicationDidFinishLaunching delegate method, or call the parsing method from the applicationDidFinishLaunching method. If it only needs to load the data under certain circumstances, then that's when I'd do it. Regardless of where in your program you do your parsing, the parsing function should be the one that controls the progress indicator inside whichever view contains it.
As for when to switch views, that all depends on how you want your program to look. Personally, if I were loading data from an XML file for display in a table, then I would post a view to the screen that had the progress indicator and a loading message. Then once the data was loaded, I'd display the populated tableview. However, if you're XML parsing is going to take a while, then you may want to look into threaded processing so you can keep your program "running" until the data is fully loaded.
As a side note: I have no desire to charge anyone for any knowledge that I want to share. Most of this stuff I figured out on my own, and it's no fun when you're trying to do something and you can't find any help. I'll do my best to answer any question that anyone may have.
- (void)awakeFromNib {
//your code here!
}
Why does TwoViewAppViewController.h have a member variable "theLabel", and why is it linked in the layout editor? It is not used in the actual source code, but if I comment it out (project still compiles) but the app crashes immediately. It seems a bit odd to me that there is also a "theLabel" member variable in MainView.h as well - but then again, everything in obj-c and cocoa seems odd to me!
Thanks
Just a little problem, but it took me a long time to figure that one out.
Thanks again for a super video.
Thank you. This tutorial is great.
Quick question: If I wanted to add a ThirdView, and FourthView could I just copying the way SecondView was added?
Thanks again.
The only thing I don't understand is why do you have to nullify secondViewController at the end of flipToFront? If I don't do it, it will crash, and I can't understand why.
Second, I also tried nullifying it with [self setSecondViewController:nil] and that simply crashes, can't understand why either!
Also, in the same function, I used cache:YES, because it made much more sense to allow the API to cache the screen if I will release the only reference it has (thus deallocating it!)
I even thought it should have been crashed if I used cache:NO because it would've been looking into an invalid pointer or something.
I come from a very strong C++ background and this memory management model still gives me headaches! :D
Best regards!
[window addSubview:viewController.view];
Any idea what would cause the fail?
Thanks,
Neil
Great tutorial BTW. Cleared up a few questions I had.
Thanks.
Thanks again and look forward to more if possible.
Great tutorial, nice flow and still clear:)
I have done a lot of basic stuff and now have a "view-flowchart" for quite a big app that incorporates pageControls, scrollViews, tableViews .. you name it.
I know this is were the design patterns come in handy but I can't just incorporate my Flash/Java patterns directly as the iPhone and Objective C is a different beast.
Would it still be "best practice" to move transitions and view loads into the appDelegate, even if that would mean a seriously amount of code or is there some way to group functionality and have the delegate just activate these groups. i.e. if I have a scrollView - PageControl that could potentially transition to a set of tableViews that again could transition to a set of searchViews. Is there a way to write Controllers that control chunks of views and have them controlled from the delegate?
This is some of the info that is never covered in the books or developer docs… every frameWork I have worked with, the examples always stops when it is getting to look like a "real app".
Hope to see some new tutorials from You!
Cheers:)
Best iPhone development tutorial I've found.
Thumbs up!