如何停止动画和滑动子视图,同时在iphone中翻转动画



我使用以下代码在iphone应用程序中从一个视图导航到另一个视图。

-(IBAction)navigateToInfo:(id)sender
{
    InfoDetailViewController *vc=[[InfoDetailViewController alloc]init];
   //[self.navigationController pushViewController:vc animated:YES];
   // [vc release];
    self.view.backgroundColor=[UIColor blackColor];
      [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    for(UIView *view1 in self.view.subviews)
    {
        [view1 removeFromSuperview];
    }

    [self.view addSubview:vc.view];
    [UIView commitAnimations];
}

-(IBAction)navigateToMainScreen:(id)sender
{ 
    MainVC *vc=[[MainVC alloc]init];

    [UIView beginAnimations:nil context:NULL];
      [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    [UIView setAnimationDuration:1.0];
      self.view.backgroundColor=[UIColor blackColor];
    for(UIView *view1 in self.view.subviews)
    {
        [view1 removeFromSuperview];
    }
    [self.view addSubview:vc.view];
    [UIView commitAnimations];
}

但它也会将导航栏按钮项、按钮等子视图与主视图一起滑动。如何防止子视图更改其位置?

This solved the issue.

-(IBAction)navigateToInfo:(id)sender
{
    InfoDetailViewController *vc=[[InfoDetailViewController alloc]init];
    self.view.backgroundColor=[UIColor blackColor];
      [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view.window cache:YES];
    [UIView commitAnimations];
  [self.navigationController pushViewController:vc animated:YES];
    [vc release];

}

最新更新