我在appdelelagte 中设置了跟试图,为root,在root 里写了一个tabbar ,然后其中有一个界面,判断是否登录,登录present ,在root 试图中 [self presentViewController:bar animated:NO completion:^{
}];
调用的tabBar ,但是就出现了 Presenting view controllers on detached view controllers is discouraged <L_RootViewController: 0x7fb6b3514850>.
警告,请问怎么解决
}];
调用的tabBar ,但是就出现了 Presenting view controllers on detached view controllers is discouraged <L_RootViewController: 0x7fb6b3514850>.
警告,请问怎么解决
如下方法应该可以解决你的问题:
你应该从window.rootController 中来present出来登录视图。所以弹出登录的代码你放到AppDelegate中。例如如下代码-(void)showLogin {
UITabBarcontroller *tabController = (UITabBarcontroller *)self.window.rootViewController;
LoginViewController *login = [LoginViewController new];
[tabController presentViewController:login animated:NO completion:nil];
}在别的类中可以通过NSNotification 来调用AppDelegate中的这个 showLogin方法