【问题标题】:iPhone view appearing behind animationiPhone 视图出现在动画后面
【发布时间】:2011-01-15 23:53:28
【问题描述】:

我设置了一个具有两个视图的多视图应用程序。可以使用每个视图中的按钮切换视图(有两个单独的操作)。我正在使用动画 UIViewAnimationTransitionFlipFromRight,当我从第一个视图转到第二个视图时,我要看到的视图出现在翻转动画的后面。我希望它只是白色的。任何帮助表示赞赏。

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

【问题讨论】:

    标签: iphone views animation


    【解决方案1】:

    如果 comming.view 为 nil 可能会出现这种错误

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

    检查一下,可能你的笔尖没有正确加载

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

    【讨论】:

      【解决方案2】:

      您可以尝试使用 addSubView,它只是将它添加到堆栈的顶部。

      【讨论】:

      • 如 [self.view addSubview: comming.view]; ?
      猜你喜欢
      • 2018-03-23
      • 1970-01-01
      • 2018-08-25
      • 2013-02-01
      • 1970-01-01
      • 2011-02-08
      • 2016-08-06
      • 1970-01-01
      • 2018-05-18
      相关资源
      最近更新 更多