More
See all Show me
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

Credits

44 Likes

  • Brandon Mullins 1 year ago
    You sir are a wizard!

    Great video. :D
  •  
  • David Widman 1 year ago
    This is one of the best video tutorials I've seen!!!! Keep the great job!!!

    Can you make one tutorial for the table view?

    Congratulations on your excelent video.
  •  
  • Nick Myers 1 year ago
    @Mona Sembal

    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.
  •  
  • Dick Applebaum 1 year ago
    This is a very good tutorial! Keep it up.

    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
  •  
  • Nick Myers 1 year ago
    To answer your questions, it seems to be good form to leave the MainWindow.xib alone and create your own. However, I have made simple, single view apps that used only the MainWindow.xib. My advice is to use multiple XIBs if your program is going to be more intricate.

    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.
  •  
  • Nick Myers 1 year ago
    I have had similar problems with apps that I wanted to be in landscape mode. The best solution that I've come up with is making a rotation transform and setting it as the transform for the view you're wanting to display. You'll also need to set the center or the view after the rotation equal to the center of the window.
  •  
  • Nick Myers 1 year ago
    There's bound to be a way to do it, but I haven't delved that deep into trying to make it work.....I'll let you know if I figure anything out.
  •  
  • Christopher Brown 1 year ago
    Hi nick, first thank you for a excellent tutorial. I have been going round in circles trying to figure this out with no luck. I do have one question though, when the view is added as a subview in the AppDelegate the initWithFrame method, inside whichever nib is loaded, is not invoked as it wasn't called. How do i ensure that my instance variable are initialised when the view loads, is there an equivalent of awakeFromNib in the iPhone SDK?
  •  
  • Nick Myers 1 year ago
    awakeFromNib is supported by the iPhone SDK. You can add it to your view controller's .m file to do any extra initialization.

    - (void)awakeFromNib {
    //your code here!
    }
  •  
  • roberthuttinger 1 year ago
    from someone who is dyslexic, great tutorials like this keep me from asking simple questions on a forum and getting flamed. I learn best from watching, so I can focus on why something is done and not how to type it in. Thanks for your time!
  •  
  • Nick Myers 1 year ago
    Glad I could help.
  •  
  • This comment has been deleted.


  • Josh B 4 months ago
    How did you set up 3 views?
  •  
  • markww 1 year ago
    I downloaded the sample project -

    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
  •  
  • Nick Myers 1 year ago
    I was playing around with making the label's color change without having to press the button. Just ignore it.
  •  
  • darl 11 months ago
    Great video! I learned a lot from this. Thanks for sharing this Nick
  •  
  • Anton Sinelnyk 10 months ago
    Great tutorial, thank you very much!
  •  
  • Anton Sinelnyk 10 months ago
    One more time thank you. This is the greatest tutorial I've ever seen.
  •  
  • Tom King 9 months ago
    When I finished creating all the files and got onto the TwoViewAppAppDelegate.h, the IBOutlet lines were missing from the @interface section. Any ideas?
  •  
  • Kim Kantola 7 months ago
    Thanks so much. Just wanted to post a problem I had in case anyone else finds the same issue. I was getting an error upon clicking my button which should have switched me to the second xib view. Turns out, when you click "Build and Go", you are not prompted to save "xib" file edits like you are for .m or .h files. So, though my xib file was fine, I got an error since my latest changes to it weren't saved and built. Once I manually saved it and rebuilt, all was fine.

    Just a little problem, but it took me a long time to figure that one out.

    Thanks again for a super video.
  •  
  • tom do 7 months ago
    Has anyone figured out how to make the second window go to Landscape mode? I can start in landscape mode but I can't make the second window go to landscape mode. I've done the same things Mike P did.
  •  
  • Stephen Young 7 months ago
    An absolutely fabulous video ... I am so glad I just happened to find it. The Objective-C/iPhone OS world is extremely "awkward" and unintuitive and while Apple has a ton of documentation out there it is resources like this video that bring it to life. Thank you, thank you, thank you!
  •  
  • Robert DeLuca 6 months ago
    If you want I can get you a version of ScreenFlow? Its better :)
  •  
  • Bryan Benetti 6 months ago
    Hi,
    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.
  •  
  • anees 5 months ago
    thank you very much. Excellent video. keep posting.
  •  
  • Charles graffeo 5 months ago
    Dude Your a genius right now im an intern at a company in nyc and im programming an app for them , this defitenly helped with multiple views , with the book i had it made it hard to understand how to link everything together in the interface menu but you i learned what to do in like a half hour kudos man kudos
  •  
  • Charles graffeo 5 months ago
    also if you can make a video of how to read in rss feeds to an i phone app that will surely be apprecieated
  •  
  • Matias Pequeno 5 months ago
    Excellent tutorials, I love them. Keep up the great work.

    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!
  •  
  • Josh B 4 months ago
    Excellent video! I cant for the bloody life of me though, figure out how to add 2 flips (one to the left and one to the right) with 2 separate buttons on the main page. That second button just wont flip at all. Any ideas?
  • Josh B 4 months ago
    Ive got 2 functional buttons, but they both always got to the same place, i cant get them to each go to a different page
  •  
  • Neil Brightcliffe 1 month ago
    Sorry this may be a little old for me to be posting to. But I have tried numerous examples of multi view tutorials and they all fail when doing something like this in applicationDidFinishLaunching from your example:

    [window addSubview:viewController.view];

    Any idea what would cause the fail?

    Thanks,
    Neil
  •  
  • Neil Brightcliffe 1 month ago
    It's ok guys, got it working. Don't know how but never mind.

    Great tutorial BTW. Cleared up a few questions I had.

    Thanks.
  •  
  • Patrick O'Sullivan 20 days ago
    Amazing set of videos Nick, they have been more helpful then you know. I am very new to macs and iphone dev in general and these have started me well on my way to understanding the architecture. I have been messing around with the code to make the color of the text change after you select it from the secondView without having to press the button again, but when I return to the first (mainview) the whole view seems to jump up a few pixels and offsets everything. The color does change though, and then they rejoiced. I release and then re-load the initial xib file after the color selection so I am very confused, if its re-loaded from scratch, how this could happen. Any ideas whats wrong?

    Thanks again and look forward to more if possible.
  •  
  • Ricki Gregersen 17 days ago
    Hi Nick
    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:)
  •  
  • john sneddon 15 days ago
    Great tutorial. Thank you for taking the time to create it. I appreciate your explanations coming from .Net to iPhone development. Keep them coming!
  •  
  • Tamer 3 hours ago
    Thank you for this great tutorial!
    Best iPhone development tutorial I've found.
    Thumbs up!
  •  
This conversation is missing your voice. Take five seconds to join Vimeo or log in.

Advertisement

Statistics

  •  
    plays
    likes
    comments
  • Total
    plays 16K
    likes 45
    comments 36
  • Nov 12th
    plays 20
    likes 0
    comments 1
  • Nov 11th
    plays 43
    likes 0
    comments 0
  • Nov 10th
    plays 45
    likes 0
    comments 0
  • Nov 9th
    plays 32
    likes 0
    comments 0
  • Nov 8th
    plays 31
    likes 0
    comments 0
  • Nov 7th
    plays 30
    likes 0
    comments 0
  • Nov 6th
    plays 22
    likes 0
    comments 0
  • Nov 5th
    plays 36
    likes 0
    comments 0
Previous Week

Downloads

Please join Vimeo or log in to download the original file. It only takes a few seconds.