Search code examples
objective-cuiviewcore-animation

Strange graphics glitch when using flip animation


I'm getting a strange error when committing a flip animation. These three bars show up, almost like strips that aren't being drawn too.

I got a screenshot to show what I'm talking about. These lines are always in the same place, and show up on both sides.

graphics glitch screenshot http://img263.imageshack.us/img263/6079/animationglitch.jpg

Here is the code that I'm using, I've used it before without problems, so I'm not sure whats goin on.

-(void)switchView
{   
    BOOL isChangingToMapView = _mapViewController.view.superview == nil;
    CGContextRef context = UIGraphicsGetCurrentContext();


    [UIView beginAnimations:nil context:context];
    [UIView setAnimationDuration:1];
    [UIView setAnimationTransition:(isChangingToMapView ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) forView:self.view cache:YES];

    if (isChangingToMapView) 
    {
        [_mapViewController viewWillAppear:YES];
        [_listViewController viewWillDisappear:YES];

        [_listViewController.view removeFromSuperview];
        [self.view insertSubview:_mapViewController.view atIndex:0];

        [_listViewController viewDidDisappear:YES];
        [_mapViewController viewDidAppear:YES];
    } 
    else 
    {
        [_listViewController viewWillAppear:YES];
        [_mapViewController viewWillDisappear:YES];

        [_mapViewController.view removeFromSuperview];
        [self.view insertSubview:_listViewController.view atIndex:0];

        [_mapViewController viewDidDisappear:YES];
        [_listViewController viewDidAppear:YES];
    }

    [UIView commitAnimations];
}

Any ideas as to what could be causing this?


Solution

  • Well I banged my head off of this problem for awhile and then moved on. Then I had the bright idea to try it on the actual phone. Sure enough it runs properly on the phone.

    Just a little reminder, if you are having weird problems developing on the simulator, at least try your app on the phone before you waste to much time chasing a bug made by the simulator.