0

我在 xcode-4.2 中进行了编码,在更新 xcode-4.5.1 后,我的应用程序运行良好,同时单击窗口导航它显示以下错误。

Warning: Attempt to present <learnview: 0x8876220> on <UINavigationController: 0x8866e10> whose view is not in the window hierarchy!

我将函数从 viewdidload() 更改为 viewdidappear() 仍然显示相同的错误?请帮我解决

编辑:

    -(void)goright
   {
    CATransition* transition = [CATransition animation];
    transition.duration = 1.5;
   transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
    transition.type = kCATransitionPush;
    learnview *lview=[[learnview alloc]initWithNibName:@"learnview" bundle:nil];
    transition.subtype = kCATransitionFromRight; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
    [self.navigationController.view.layer addAnimation:transition forKey:nil];
   [[self navigationController] pushViewController:lview animated:NO];

    [imagetim invalidate];    
    }     
4

1 回答 1

0

viewWillAppear:在或中调用此方法viewDidAppear:

用动画试试下面的代码......

-(void)goright
{
    CATransition *animation = [CATransition animation];
    [animation setDelegate:self];   
    [animation setType:kCATransitionPush];
    [animation setDuration:1.5];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                                  kCAMediaTimingFunctionEaseInEaseOut]];
    [animation setSubtype:kCATransitionFromRight];
    [[self.view layer] addAnimation:animation forKey:@"transitionViewAnimation"];

    learnview *lview=[[learnview alloc]initWithNibName:@"learnview" bundle:nil];
    [[self navigationController] pushViewController:lview animated:NO];

    [imagetim invalidate];    
}

没有动画试试下面的代码......

-(void)goright
    {

        learnview *lview=[[learnview alloc]initWithNibName:@"learnview" bundle:nil];

        [self.navigationController pushViewController:lview animated:YES];

        [imagetim invalidate];    
    }     

尝试这个

于 2012-10-26T06:17:37.040 回答