我有一个应用程序,我在其中添加这样的视图,因为我需要它在导航栏上方。 `
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时,所有工作正常。但是当按钮按下它时它不为空它首先显示视图控制器然后它再次上升然后再来到viewcontroller.it首先没有动画然后带有动画。为什么有人可以帮我这个吗?