Question: I am practicing ios and I am trying to make simple real estate app, one viewcontroller, I put navigation bar and at the right sie of navigation bar I have button map
(I am trying to show all houses in area with basic data:street, price, long, lat... in tableview and just like marker on mapview).

I want that button to behave like toggle, to switch between table view and map view but in same controller. ( In android I could put one below other and just alternately set visibility to gone to one and visible to another). 
How to alternately switch views in same controller (view need to be all over screen) ?

Answer: 
Are you using a storyboard? Why not just perform a segue on button tap?

```
- (void)myButtonMethod
{
    //execute segue programmatically
    [self performSegueWithIdentifier: @"MySegue" sender: self];
}

```

"MySegue" would be the segue identifier that is set in the storyboard between the two views.
Add two views tableview and maple to UIViewController's view.
It would be like:

```
-(void) viewDidLoad
{
    [self.view addSubview:tableView];
    [self.view addSubview:mapView];
}

```

On button click decide which view needs to be displayed:

```
-(void) onButtonClick:(UIButton *)sender
{
     //If you want to display map..
     [self.view bringSubviewToFront:mapView];
     //If tableview needs to display
     [self.view bringSubviewToFront:tableView];
}

```