How do you turn a Tab Bar Application into a View-Based Application...

Discussion in 'iOS Programming' started by timbojill, Jun 2, 2011.

  1. macrumors member

    Joined:
    May 21, 2011
    #1
    How do you turn a Tab Bar Application into a View-Based Application. I have a Tab Bar Application already submitted into the app. View my blog and look at the learning Center. Instead of Tabs I want one view as my main view and that from the main view have buttons that switch to and from other xib files.
     
  2. macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #2
    Just delete or ignore your tab bar button functions and create UIButtons to navigate your views.
    Nick
     
  3. thread starter macrumors member

    Joined:
    May 21, 2011
    #3
    I ignored the Tab Bar and added buttons to the main view. But what is the code to have the xib files connected.
     
  4. macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #4
    Code:
    -(IBAction)changeSecondView{
    SecondView *views = [[SecondView alloc] initWithNibName:Nil bundle:nil];
    	[self presentModalViewController:views animated:NO];
    }
    You will also want to create a SecondView .h and .m file by right clicking your Class folder and selecting Add > New File. Add a UIViewController subclass (uncheck the add xib if you already have one). click Next. Set the file name to SecondView.m and make sure the Also create "SecondView.h" box is checked. Then at the top of your FirstViewController.m add
    Code:
    #import "SecondView.h"
    Nick
     
  5. timbojill, Jun 3, 2011
    Last edited by a moderator: Jun 3, 2011

    thread starter macrumors member

    Joined:
    May 21, 2011
    #5
    I tried to use a .h and .m file I already had. The name is 2nd.h and 2nd.m.

    So should it be:
    Code:
    2nd *views = [[2nd alloc] initWithNibName:Nil bundle:nil];
    	[self presentModalViewController:views animated:NO];
    
    
    ?
     
  6. macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #6
    You will be loading the xib file this way. So if your xib name is "2nd" then your code is correct. the code written in your 2nd.h and .m can be linked to your 2nd.xib (or any xib for that matter) by opening interface builder -> select your files owner -> select the last tab (i) on the identity inspector window -> change class to 2nd.

    Nick
     
  7. thread starter macrumors member

    Joined:
    May 21, 2011
  8. macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #8
    The application looks pretty messy. I believe the reason it is crashing is because you are trying to change the view from a UIView, not a UIViewController. I'd recommend starting fresh with a new view based app. It shouldn't take long since all you have now are a few buttons linked to functions you are not using. In the view based app add the .h and .m files like I said but check the box to include the xib.
    Good Luck,
    Nick
     
  9. timbojill, Jun 3, 2011
    Last edited by a moderator: Jun 3, 2011

    thread starter macrumors member

    Joined:
    May 21, 2011
    #9
    I already started from the beginning. I took an example of a view app and try to modify it. If you ran the program the first button works. I just need to find a way to add the other buttons to link to the other .h files and xib files I have.

    EDIT:

    In the example I used he added all the xib's to the main xib. I want to uses other xibs I imported.

    EDIT 2:

    http://www.mediafire.com/?swbm2ksyefdzzm3 nick I hope you still around. I started from the beginning with a new view-based project. In the LC4Viewcontroller.m I get an error in the IBAction that calls the first views from the main view.

    Code:
    
    - (IBAction)view2 {
        [self addSubview:Letter];
    }
    
    
    The error is expected expression before letter. Can anyone help me out.

    EDIT 3:

    Can someone add a third view called view3 and connect it for me. When I did it it said view3 undecleared. I don't know why I am having so much trouble.

    http://www.esnips.com/doc/66bb2e0c-173a-4ce7-8685-4969b13db895/new
     

Share This Page