2009-07-23 98 views
1

提交翻转动画时出现奇怪的错误。这三个条显示出来,几乎就像没有被绘制的条。使用翻转动画时出现奇怪的图形故障

我有一张截图来展示我在说什么。这些线条总是在同一个地方,并在双方都显示出来。

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

这里是我正在使用的代码,我之前已经用它没有问题,所以我不知道什么布莱恩。

-(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]; 
} 

任何有关可能导致此问题的想法?

回答

1

好吧,我一会儿就把这个问题搞砸了,然后继续前进。然后我有一个好主意,可以在实际的手机上试用它。果然,它可以在手机上正常运行。

只需稍微提醒一下,如果您在模拟器上开发出奇怪的问题,至少在手机上试用您的应用程序,然后再浪费很多时间来追踪模拟器发出的错误。