【问题标题】:how to stop animation and sliding subviews while flipleft animation in iphone?如何在iphone中翻转动画时停止动画和滑动子视图?
【发布时间】:2012-02-18 10:37:35
【问题描述】:

我正在使用以下代码在 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];

}

但它也会与主视图一起滑动 uinavigation bar button item、button 等子视图。如何防止子视图改变它们的位置 ?

【问题讨论】:

    标签: iphone animation subview flip


    【解决方案1】:
    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];
    
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-22
      • 1970-01-01
      • 2017-03-29
      • 1970-01-01
      • 2011-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多