views:

101

answers:

1

I have a UIViewController with an MKMapView in it. In viewDidLoad of this controller, I add the MKMapView:

[self.view addSubview:mapView];

I want to display this map in a tableview cell. In the tableview controller's cellForRowAtIndexPath:, I do this:

[cell addSubview:mapView.view];

where cell is a UITableViewCell. I've set the mapview frame to

mapView.frame = CGRectMake(0, 0, 200, 100);

The mapview appears to the bottom left of the cell. Meaning, it is partially in the cell and also out of it. The map overlaps much of the cell but I want it to fill the cell and be bounded by it. How can that be done?

There isn't an associated xib for these controllers.

--- EDIT ------

The tableview is styled as grouped. It looks as though I just need to do some trial and error offsetting to get the map matched up correctly.

A: 

did you try setting the clipbounds property on the mapview?

ennuikiller
I set clipbounds to true on the mapview and UIViewController. Doesn't make any difference
4thSpace