2

我有一个应用程序,我在其中添加这样的视图,因为我需要它在导航栏上方。`

 AppDelegate *appDelegate = (AppDelegate  *)[[UIApplication sharedApplication] delegate];

    if(appDelegate.viewcontroller==nil)
    {
        appDelegate.viewcontroller = [[ViewController alloc] init];
        CATransition *animation = [CATransition animation];
        [animation setType:kCATransitionPush];
        [animation setSubtype:kCATransitionFromTop];
        [animation setDuration:0.5f];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                                      kCAMediaTimingFunctionEaseInEaseOut]];
        [appDelegate.viewcontroller.view.layer addAnimation:animation forKey:@"someTransition"];
        [self.navigationController.view addSubview:appDelegate.viewcontroller.view];
        [appDelegate.viewcontroller viewWillAppear:YES];  
   }
    else
    {       
          CATransition *animation = [CATransition animation];
        [animation setType:kCATransitionPush];
        [animation setSubtype:kCATransitionFromTop];
        [animation setDuration:0.5f];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                                      kCAMediaTimingFunctionEaseInEaseOut]];
        [appDelegate.viewcontroller.view.layer addAnimation:animation forKey:@"someTransition"];        
        [self.navigationController.view addSubview:appDelegate.viewcontroller.view];
        [appDelegate.viewcontroller viewWillAppear:YES];        

    }

它被删除了

self.view removefromsuperview

当 appDelegate.viewcontroller 为 nil 时,一切正常。但是当按下按钮时它不为 null那么,有人可以帮我吗?

4

0 回答 0