2012-01-25 22 views
0

我正在使用以下代碼從iPhone應用程序中的一個視圖導航到另一個視圖。如何在iPhone中使用flipleft動畫時停止動畫和滑動子視圖?

-(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欄按鈕項,按鈕等子視圖也隨着主view.How防止子視圖從改變自己的立場 ?

回答

0
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]; 


}