Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Well, this is what I want to do in my app: I would like to implment a UIView with a map on the top half of the screen and a tableview on the other half with two buttons in the middle. If I press one of the buttons the map will get fullscreen and if I press the other one the tableView will fit all the screen.

Any suggestion?

like image 265
sergiocg90 Avatar asked Apr 05 '12 17:04

sergiocg90


2 Answers

In one view controller like a UINavigationController create an MKMapView with a frame the size of the top half of the view and add it as subview of your view controller. Then I would create a UIToolbar to hold your buttons and make the top of it's frame line up with bottom of the MKMapView. Finally create a UITableView with it's frame just below the others (make sure you hook up it's delegates).

Then assign the target of your UIBarButtonItem that makes the map go fullscreen to a method that animates the frames of all three views like this:

[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){}
 ];
like image 62
Steve Moser Avatar answered Oct 14 '22 17:10

Steve Moser


Create both views how you are planning, On one button click, change the frame of one view to fit the full screen, if you click the other button, do the same thing to the other view.

like image 39
PRNDL Development Studios Avatar answered Oct 14 '22 16:10

PRNDL Development Studios