我的應用層次正在尋找這樣的:推到特定的viewController從AppDelegate中
tabBarController >> navigationControllers (multiple) >> viewControllers (multiple)
當某個事件發生在appDelegate
我要推一個特定的viewController在navigationControllers之一。現在我有這樣的:
UINavigationController *myNavigationController = [[(UITabBarController*)self.window.rootViewController viewControllers] objectAtIndex:0];
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
StoreViewController *targetViewController = (StoreViewController*)[mainStoryboard instantiateViewControllerWithIdentifier:@"StoreViewController"];
[myNavigationController pushViewController:targetViewController animated:YES];
這隻能如果應用程序是目前在相同的navigationController的targetViewController。無論您在應用程序中的什麼位置,我都希望它能夠正常工作。謝謝!
targetViewController.navigationController的值是什麼?如果它設置爲與myNavigationController不同的值,那麼可能是導致問題 –