Change views with UISegmentedControl with another XIB on selectedSegmentIndex

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");

    }

}

Answers


In your code sample I dont't see anything that you added the UIView of your map controller to a parent view (I think self.view in your sample) with addSubview. 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.


Need Your Help

Brute-force/DoS prevention in PHP

php security brute-force ddos

I am trying to write a script to prevent brute-force login attempts in a website I'm building. The logic goes something like this:

Repeat values in a matrix (R)

r sapply cbind rep

Here is the code I am working with: