How can I create a ViewController which has a fixed MapKit above a scrolling TableView?
I am coding this using Storyboards, and while I am an experienced developer this is my first time using iOS, XCode and Objective-C. I currently have a method which kind of works, but the method which I am currently using works by setting the MapKit as the section header of the table view inside a UITableViewController and does not look right. (It works since as I have only one section that MapKit section will always be fixed while I scroll the table view.)
The code that does this looks like this:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 200.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
MKMapView *mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 200)];
return mapView;
}
Unfortunately doing this means that the scrolling bar appears alongside the Map as well as the table view. Instead, I wish the scrolling bars to only be as tall as the table view.
There are other answers around the site about doing stuff like this, but none of them mention the height of the scroll bars (and the elegance of the code.)
Any ideas?