2012-04-16 71 views
0

我正在使用自定义动画来呈现我的视图控制器。这里的代码:使用UIViewController自定义动画

-(void)launchCustomModal:(id)sender 
{ 
    UIButton *buttonClicked = (UIButton *)sender; 
    int selection; 
    selection = buttonClicked.tag; 
    [ticker removeFromSuperview]; 
    ticker = nil; 

    if (selection == 3) 
    { 
     MyViewController *myVC = [[MyViewController alloc]initWithNibName:nil bundle:nil]; 
     modalViewController= [[UINavigationController alloc]initWithRootViewController:myVC]; 
     modalViewController.navigationBarHidden = YES; 
     [modalViewController setToolbarHidden:YES]; 

     CGRect result = self.view.bounds; 
     result.origin.y = -result.size.height; 
     modalViewController.view.frame=result; 
     [self.view addSubview:modalViewController.view]; 

     [UIView animateWithDuration:.375 
         animations:^{ 
          modalViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 
         } 
         completion:^(BOOL finished) { 
          NSLog(@"Finished");   
         }]; 
    } 

    return; 
} 

我注意到这种方法使非常滞后的过渡。如果我以普通模式启动VC,它的运行非常顺利。另外,如果我独立于视图控制器创建一个视图的动画,它也可以非常流畅地运行。我想知道是否有什么关于风险投资可能导致它动画如此糟糕?如果它是我正在做的事情的一个症状,或者视图控制器不是为了这样处理,等等。任何输入都非常感谢。谢谢!

+1

固定!我从MyViewController中删除了一个阴影,现在它效果很好。猜这些很难呈现 – 2012-04-16 20:33:02

+0

是的,阴影会每次都做到。我避免他们像瘟疫一样。 – 2012-04-16 20:38:00

+0

请将您的解决方案作为正确的答案添加,这样未来的读者更容易看到您找到了解决方案:-) – 2012-08-21 15:26:24

回答

0

这是CALayer阴影。删除它们,它工作得很好。