I would like to implement a half UITableView half a MapView UIView with a button in the middle

Well, this is what I want to do in my application: I would like to implement a UIView with a map in the upper half of the screen and a table with the other half with two buttons in the middle. If I click one of the buttons, the map will get full-screen mode, and if I click on the other, the View table will fit all screens.

Any suggestion?

+7
source share
2 answers

In one view controller, such as the UINavigationController, an MKMapView is created with a frame the size of the top half of the view and adds it as a subpoint of your view controller. Then I create a UIToolbar to hold your buttons and make the top of its frame with the bottom of MKMapView. Finally, create a UITableView with it, with a frame slightly lower than the rest (make sure you include its delegates).

Then assign a target to your UIBarButtonItem, which will cause the card to go full-screen to a method that animates frames of all three types, for example:

[UIView animateWithDuration:0.24 delay:0.0 options:UIViewAnimationCurveEaseOut animations:(void (^)(void)) ^{ self.toolbar.frame = CGRectMake(0, MAP_HEIGHT_FULLSCREEN, 320, TOOLBAR_HEIGHT); self.mapView.frame = CGRectMake(0,0,320,MAP_HEIGHT_FULLSCREEN); self.tableView.frame = CGRectMake(0, MAP_HEIGHT_FULLSCREEN+TOOLBAR_HEIGHT, 320, MAP_HEIGHT_FULLSCREEN-MAP_HEIGHT); } completion:^ (BOOL finished){} ]; 
+7
source

Create both views as you plan. When you click one button, change the frame of one view to full screen, if you click on another button, do the same with the other view.

+1
source

All Articles