I am trying to update my application so that it has multiple views (it currently only has one).
I have a UIViewController called "viewSwitcher" and then 3 other view controllers that manage their own views.
In the app delegate I have made the "viewSwitcher" view a subview of the window, which works fine.
Then in the viewDidLoad method of "viewSwitcher", I insert a new subview as follows:
Again, this works fine.
Then in the "menuViewController" I have the following method:
Which calls the following method from "viewSwitcher":
You'll notice that there are nslogs and commented out code for a UIAlert - this was to check the method was actually being called - which it is.
But despite the method being executed, the newGameViewController view is not being inserted as a subview of "viewSwitcher"...
Any thoughts? (Will clarify where required )
Thanks.
Dan
I have a UIViewController called "viewSwitcher" and then 3 other view controllers that manage their own views.
In the app delegate I have made the "viewSwitcher" view a subview of the window, which works fine.
Then in the viewDidLoad method of "viewSwitcher", I insert a new subview as follows:
Code:
MenuViewController *menuController = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil];
menuViewController = menuController;
[self.view addSubview:menuViewController.view];
Again, this works fine.
Then in the "menuViewController" I have the following method:
Code:
-(IBAction)viewNewGame{
self.view.hidden = YES;
[viewSwitcher switchNewGameView];
}
Which calls the following method from "viewSwitcher":
Code:
-(void)switchNewGameView{
NSLog(@"switchNewGameView method starting");
NewGameViewController *newController = [[NewGameViewController alloc] initWithNibName:@"NewGameViewController" bundle:nil];
newGameViewController = newController;
[self.view addSubview:newGameViewController.view];
NSLog(@"switchNewGameView method finishing");
// NSString *alertText = [NSString alloc];
// alertText = [NSString stringWithFormat:@"You scored %d"];
// UIAlertView *alert = [[UIAlertView alloc]
// initWithTitle:@"Game Over"
// message:alertText
// delegate:self
// cancelButtonTitle:@"New Game"
// otherButtonTitles: nil];
// [alert show];
}
You'll notice that there are nslogs and commented out code for a UIAlert - this was to check the method was actually being called - which it is.
But despite the method being executed, the newGameViewController view is not being inserted as a subview of "viewSwitcher"...
Any thoughts? (Will clarify where required )
Thanks.
Dan