views:

16

answers:

1

I have a UIView in which I flip between a UITableView and a MKMapView. The MKMapView is created at runtime and animated in the following function:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:(self.mapView == nil ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft)
                       forView:self.topView cache:YES];
// create new map view if necc.
if (self.mapView == nil)
{
    self.mapView = [[VTMapView alloc] initWithFrame:self.topView.bounds];
    mapView.mapType = MKMapTypeStandard;
    mapView.delegate = self;
    mapView.scrollEnabled = YES;
    mapView.zoomEnabled = YES;
    mapView.showsUserLocation = YES;
    }
// map visible? show or hide it
if (![self isMapVisible])
{
    tableView.hidden = YES;
    [self.topView insertSubview:mapView aboveSubview:self.tableView];
    mapLoadCount = 0;
} else {
    tableView.hidden = NO;
    [mapView removeFromSuperview];
}
[UIView commitAnimations];

The first time it works fine, but in future runs there are horizontal bars on the top and bottom of the map view during the animation. It looks something like this:

alt text

I've tried playing with the cache setting, removing other views, etc. It doesn't happen in the simulator but it happens on OS 4.1.x and 3.1.x.

If I don't hide the tableView, I see bits of the table instead of the grey bars, so I think the mapview is being resized incorrectly during the flip.

A: 

Change this line:

UIView setAnimationTransition:(self.mapView == nil ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft)
                   forView:self.topView cache:YES];

To this line:

UIView setAnimationTransition:(self.mapView == nil ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft)
                   forView:self.topView cache:NO];

And that is the answer.

sehugg
This is a comment or an edit of the original question. It does not belong as an answer.
Nick