我在应用程序委托中创建了一个函数,我从一个视图运行,但是当我回来再次运行该函数时,它给了我
<ResultViewController: 0x757dfc0> on <ViewController: 0x71325c0> whose view is not in the window hierarchy!
错误
应用程序委托代码正在打开一个视图控制器
代码是
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ViewController *view1 = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
[self.window setRootViewController:view1];
[self.window makeKeyAndVisible];
return YES;
}
-(void)specify
{
ResultViewController *res = [[ResultViewController alloc]init];
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.window.layer addAnimation:transition forKey:nil];
[self.window.rootViewController presentModalViewController:res animated:NO];
}