2010-02-12 59 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);