开发者

Why do I see jerky animation when using this UIView animation block?

I have a a tab bar that is made in the application delegate. By calling an action form a button click from one of the views loaded from the tab bar, I open the help screen but there is a jerking motion after loading.

forgive me for speaking informally..I have been picking my brain for the past few hours trying to figure this out..

-(void)flipToHelp {
 HelpViewController *helpVariable = [[HelpViewController alloc] initWithNibName:@"HelpView" bundle:nil];
 [self setHelpViewController:helpVariable];
 [UIView beginAnimations:@"flipview" context:nil]; 
 [UIView setAnimationDuration:开发者_Go百科0.5];
 [UIView setAnimationCurve:UIViewAnimationCurveLinear];
 [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
 forView:_window cache:YES];

[_window removeFromSuperview];
[helpVariable release];
self.window.rootViewController = self.HelpViewController;
[UIView commitAnimations];
}


Just to reiterate from the comment thread, you shouldn't be removing the window from its superview (it doesn't technically have a superview, so it's probably causing problems). And setting the window's rootViewController property should swap out the view hierarchies, Apparently the jerkiness comes from changing the window's rootViewController property, so maybe the solution is to avoid using that property. Here's what I think should be enough to accomplish this:

-(void)flipToHelp {
     HelpViewController *helpVariable = [[HelpViewController alloc] initWithNibName:@"HelpView" bundle:nil];
     [UIView beginAnimations:@"flipview" context:nil]; 
     [UIView setAnimationDuration:0.5];
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:_window cache:YES];
    [self.tabBarController removeFromSuperview];
    [_window addSubview:helpVariable];
    [UIView commitAnimations];
}


-(void)flipToHelp {
  HelpViewController *helpVariable = [[HelpViewController alloc] initWithNibName:@"HelpView" bundle:nil];
  [self setHelpViewController:helpVariable];
  [helpVariable release];

  [UIView beginAnimations:@"flipview" context:nil]; 
  [UIView setAnimationDuration:0.5];
  [UIView setAnimationCurve:UIViewAnimationCurveLinear];
  [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
                         forView:self.window
                           cache:YES];

  self.window.rootViewController = self.HelpViewController;
  [UIView commitAnimations];
}

How about this code? Does it still have a jerky animation?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜