My Question is…
On my UISegmentedControl, I created two buttons on navigationItem, on button one I show my own class and another button I need show another XIB, the only thing I’m missing is how I show this another class ?
-(IBAction)segmentAction:(id)sender
{
UISegmentedControl *segmentedControl = (UISegmentedControl *)sender;
segmentedControl.momentary = YES;
NSInteger selectedSegment = segmentedControl.selectedSegmentIndex;
MapViewController *mapController = [[MapViewController alloc]init];(Other class)
if(selectedSegment == 0) {
[self.view setHidden:NO];(MOSTRA)
[mapController.view setHidden:YES];
NSLog(@"Lista");
} else {
[self.view setHidden:YES];
**[mapController.view setHidden:NO];(Dont show anything)**
NSLog(@"Mapa");
}
}
In your code sample I dont’t see anything that you added the
UIViewof your map controller to a parent view (I think self.view in your sample) withaddSubview. So it can’t be visible.Since iOS 5 you should use container view controllers to manage the views you add from other UIViewController subclasses.
UIViewController Class Reference
The best solution would be, that you have a parent controller that includes the both view controllers you want to use to switch between.
Or maybe UITabViewController is a solution for you, which is used to swtich between different
UIViewController. But I think you want some customization, so the prior solution should work.