views:

26

answers:

1

Hi there,

I am currently working on an application in which I am making a catalogue that will contain different products. So far I have made my startup menu, which includes three buttons (one for the catalogue, one for settings and one for instructions). When pressing the catalogue button, the app switches to the CatalogueViewController, and it is from within this ViewController that the catalogue should start.

Besides the startup menu, I have written the app for the catalogue in another separate app. The catalogue app is made with a TabBarController, while the startup menu is made with regular ViewControllers. My next step is to combine these two applications, so that when the catalogue button is pressed, it should open the catalogue.

Until now, when I press the catalogue button, I create an instance of my UICatalogueTableViewController which is a subclass of UITableViewController, and load my CatalogueView.xib along with it.

The ViewController header file that manages which view to be displayed:

@class MenuViewController;
@class UICatalogueTableViewController;
@class SettingsViewController;
@class InstructionsViewController;

@interface IkeaViewController : UIViewController {
    MenuViewController *menuViewController;
    UICatalogueTableViewController *catalogueViewController;
    SettingsViewController *settingsViewController;
    InstructionsViewController *instructionsViewController;
}

@property (retain, nonatomic) MenuViewController *menuViewController;
@property (retain, nonatomic) UICatalogueTableViewController *catalogueViewController;
@property (retain, nonatomic) SettingsViewController *settingsViewController;
@property (retain, nonatomic) InstructionsViewController *instructionsViewController;

-(IBAction)catalogueButtonPressed:(id)sender;
-(IBAction)settingsButtonPressed:(id)sender;
-(IBAction)instructionsButtonPressed:(id)sender;

@end

The method that is called when pressing the catalogue button:

- (IBAction)catalogueButtonPressed:(id)sender{
    if (self.catalogueViewController.view.superview == nil) {
        if (self.catalogueViewController == nil) {
            UICatalogueTableViewController *catalogueController = [[UICatalogueTableViewController alloc]initWithNibName:@"CatalogueView" bundle:nil];
            self.catalogueViewController = catalogueController;
            [catalogueController release];
        }
        [menuViewController.view removeFromSuperview];
        [self.view addSubview:catalogueViewController.view];
    }
}

Inside my .xib file (CatalogueView.xib) I have created a TabBarController object, and my files owner has its class identity set to UICatalogueTableViewController but I can't seem to connect the two, so that the TabBarController is displayed when running the app. The files owner requires a view.

When pressing the settings or instructions button in my startup menu, there is no problem when instantiating their ViewController and loading the .xib files, because they only contain a single view to be displayed.

How do I go from my startup menu (a regular ViewController) to my catalogue (TabBarController)?

Thanks in advance.

A: 

This is a very odd way to have created an app. However you should be able to disclose to a UITabBarController in a navigation controller stack. I don't see any reason why this wouldn't be possible.

Otherwise, you could import your code from your other app and then when you click on the button you can do [self presentModalViewController:myTabBarController animated:YES]; and this will give the same functionality.

Thomas Clayson