I'm currently making a tab bar application with each tab having a completely different application. I'm having a lot of difficulty visualizing how to set up one of the tabs.
What I want to do is have a segmented control with two options (I call them Test House and Corner). When the segmented control = 0, the nib file representing the test house will be shown (simply a UIViewController) and when the segmented control = 1, the nib file representing the Corner will be loaded (also a UIViewController). I use a separate nib for the Test House and corner since there will be a lot of images on each nib, making it too cluttered to code on just one view.
Currently I have three nibs, each with their own controller - one for the segmented control view, and one for each of the nibs I want to switch between. My thought process was to have the Segmented control view always showing, and would push the other two nibs based on the segmented control. Unfortunately, I'm not able to get any of the code to work, probably due to the fact that my setup is completely wonky.
My viewDidLoad method in the class with the segmented control:
- (void)viewDidLoad {
[super viewDidLoad];
QSDTIntegratedAppAppDelegate *delegate = (QSDTIntegratedAppAppDelegate *)[[UIApplication sharedApplication] delegate];
if (segmentedControl == 0) {
[delegate.testHouseViewController pushViewController:interactiveTestHouseViewController animated:YES];
}
else {
[delegate.testHouseViewController pushViewController:interactiveCornerViewController animated:YES];
}
}
My function to read when segmented control changed:
- (void) segmentAction:(id)sender{
self.segmentedControl = sender;
QSDTIntegratedAppAppDelegate *delegate = (QSDTIntegratedAppAppDelegate *)[[UIApplication sharedApplication] delegate];
if ([segmentedControl selectedSegmentIndex] == 1) {
NSLog(@"TEST HOUSE CHOSEN!");
[delegate.testHouseViewController popViewControllerAnimated:YES];
[delegate.testHouseViewController pushViewController:interactiveTestHouseViewController animated:YES];
}
if ([segmentedControl selectedSegmentIndex] == 1) {
NSLog(@"CORNER CHOSEN!");
[delegate.testHouseViewController popViewControllerAnimated:YES];
[delegate.testHouseViewController pushViewController:interactiveCornerViewController animated:YES];
}
}
TestHouseViewController = Controller for segmented control nib InteractiveTestHouseViewController = Test House nib. Choice 1 in segmented control InteractiveCornerHouseViewController = Corner nib. Choice 2 in segmented control
I get the following warning 6 times too, leaving me stumped: "TestHouseViewController" may not respond to '-pushViewController:animated:
Any help is appreciated.