How to switch views with animation - goal c

I have a viewController that has a tableView and a mapView, and only one view. I also have a toolbar with segment control with two buttons (list and map)

How to switch between table view and map view? and it’s important that the toolbar remains locked without an animation with views.

+6
source share
3 answers

After I thought I found a solution, add another container view to view the tables and display the map.
This way I can do:

[UIView transitionWithView:self.someContainerView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ self.mapView.hidden = !showingMapView; self.tableView.hidden = showingMapView; } completion:nil ]; 

without switching toolbars

+8
source

You can use the UIView animation UIView by passing the transition supervisor:

 - (IBAction)segmentIndexChanged { BOOL showingMapView = (BOOL)self.segmentedControl.selectedSegmentIndex; [UIView transitionWithView:self.view duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ self.mapView.hidden = !showingMapView; self.tableView.hidden = showingMapView; } completion:nil]; } 
+4
source

Try entering the code for the show and mapview tables:

Hide table view and table view in segmented ControlIndexChanged:

 - (IBAction)segmentedControlIndexChanged { switch (self.segmentedControl.selectedSegmentIndex) { case 0: //it show tableview [UIView transitionWithView: self.view duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ self.mapView.hidden = YES; self.tableView.hidden = NO; } completion:nil]; break; case 1: //it show mapview [UIView transitionWithView:self.view duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ self.mapView.hidden = NO; self.tableView.hidden = YES; } completion:nil]; break; default: break; } } 
+1
source

Source: https://habr.com/ru/post/913774/


All Articles