2010-02-12 54 views
1

我已經建立了一個具有兩個視圖的多視圖應用程序。可以在每個視圖中使用按鈕切換視圖(有兩個獨立的操作)。我正在使用動畫UIViewAnimationTransitionFlipFromRight,當我從第一個視圖轉到第二個視圖時,我要出現的視圖出現在翻轉動畫的後面。我希望它只是白色。任何幫助表示讚賞。iPhone視圖出現在動畫背後

alt text http://img35.imageshack.us/img35/9982/picture11wu.png

這是操作開關的觀點:

- (IBAction)switchViewsOne:(id)sender 
{ 

if (self.uLViewController == nil) 

{ 

ULViewController *uLController = 

[[ULViewController alloc] 

initWithNibName:@"ULView" 

bundle:nil]; 

self.uLViewController = uLController; 

[uLController release]; 

} 

    [UIView beginAnimations:@"View Flip" context:nil]; 
    [UIView setAnimationDuration:1.25]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

    UIViewController *comming = nil; 
    UIViewController *going = nil; 
    UIViewAnimationTransition transition; 

    if (uLViewController.view.superview == nil) 
    { 
     comming = uLViewController; 
     going = mainViewController; 
     transition = UIViewAnimationTransitionFlipFromLeft; 
    } 

    [UIView setAnimationTransition: transition forView:self.view 
          cache:YES]; 
    [comming viewWillAppear:YES]; 
    [going viewWillDisappear:YES]; 
    [going.view removeFromSuperview]; 
    [self.view insertSubview: comming.view atIndex:10]; 
    [going viewDidDisappear:YES]; 
    [comming viewDidAppear:YES]; 


    [UIView commitAnimations]; 
} 

回答

0

你可以嘗試使用addSubView剛剛將其添加到堆棧的頂部。

+0

加載在[self.view addSubview:comming.view ]。 ? – potato 2010-02-13 00:02:14

0

這種錯誤可能是如果comming.view是零

[self.view insertSubview: comming.view atIndex:10]; 

檢查,也許你的筆尖不能正常

ULViewController *uLController = [[ULViewController alloc] initWithNibName:@"ULView" bundle:nil]; 
NSLog(@"Loaded controller %@:", uLController);