Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios7 在iOS中通过URLScheme启动特定的viewController_Ios7_Uiviewcontroller_Uistoryboard_Url Scheme - Fatal编程技术网

Ios7 在iOS中通过URLScheme启动特定的viewController

Ios7 在iOS中通过URLScheme启动特定的viewController,ios7,uiviewcontroller,uistoryboard,url-scheme,Ios7,Uiviewcontroller,Uistoryboard,Url Scheme,我想在电子邮件中发送一个链接来启动特定的UIViewController(它实际上是一个UITableViewController)。我可以使用CustomURL方案从链接打开我的应用程序,我已经编写了URLHandler方法(最新的方法不是不推荐的方法),我可以解析URL,但我就是无法打开页面。我使用的是故事板,一个uinavigator控制器和uitabarcontroller。我要打开的场景的故事板ID是“ApprovalView” 当我运行以下代码时,出现以下错误: UIViewCont

我想在电子邮件中发送一个链接来启动特定的UIViewController(它实际上是一个UITableViewController)。我可以使用CustomURL方案从链接打开我的应用程序,我已经编写了URLHandler方法(最新的方法不是不推荐的方法),我可以解析URL,但我就是无法打开页面。我使用的是故事板,一个uinavigator控制器和uitabarcontroller。我要打开的场景的故事板ID是“ApprovalView”

当我运行以下代码时,出现以下错误:

UIViewControllerHierarchyInconsistency',reason:'一个视图一次最多只能与一个视图控制器关联!看法层=;contentOffset:{0,0}>与 我现在从应用程序中的一个按钮运行它。如果我真的点击URL链接,应用程序就会挂起

我查看了其他关于这个错误的StackOverflow帖子,这似乎意味着我已经将一个视图连接到了两个ViewController。我相信这是因为这条线

ApprovalViewController*appViewController= [情节提要实例化eviewController标识符:@“ApprovalView”]

然而,我认为建议的解决方案似乎不起作用,因为我使用的是右舷。我可以打电话给我的segue吗

任何帮助都将不胜感激

    - (BOOL)application:(UIApplication *)application
                  openURL:(NSURL *)url
        sourceApplication:(NSString *)sourceApplication
               annotation:(id)annotation {

      // Get the host and query
      // the host is what expense to go to and the query is the noteID
      NSString *tmpHost = [[NSString alloc] init];
      tmpHost = [[url host] substringFromIndex:1];
      NSString *tmpQuery = [[NSString alloc] init];
      tmpQuery = [url query];

      // Go to a page

      // UIViewController *expenditureView =
      //      [storyboard instantiateViewControllerWithIdentifier:@"ApprovalView"];

      // UINavigationController *navVC = [[UINavigationController alloc]
      // initWithRootViewController:expenditureView];

      //    UIViewController *expenditureController =
      //    [self.window.rootViewController.storyboard
      //    instantiateViewControllerWithIdentifier:@"ApprovalView"];
      //    UINavigationController *navVC =
      //    [self.window.rootViewController.storyboard
      //    instantiateViewControllerWithIdentifier:@"navigationController"];
      //    UIViewController *currentVC = self.window.rootViewController;
      //    _window.rootViewController = navVC;
      //    [currentVC presentViewController:navVC animated:NO completion:nil];

      UIStoryboard *storyboard =
          [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];

      ApprovalViewController *appViewController =
          [storyboard instantiateViewControllerWithIdentifier:@"ApprovalView"];
      UINavigationController *navController = [appViewController.storyboard
          instantiateViewControllerWithIdentifier:@"navigationController"];
      navController.view = appViewController.view;
      _window.rootViewController = navController;
      UIViewController *currentVC = self.window.rootViewController;
      [currentVC presentViewController:navController animated:NO completion:nil];

      // [self.window addSubview:self.navVC.view];
      // [self.window setRootViewController:self.navVC];

      // Navigation

      // UINavigationController *navCon = [[UINavigationController alloc] init];
      //[navVC pushViewController:expenditureView animated:NO];

      //[expenditureView.navigationController setNavigationBarHidden:FALSE
      // animated:YES];

      // self.window.rootViewController = expenditureView;

      return YES;
    }

可能问题是每个选项卡都应该有不同的导航控制器?不,只有一个导航控制器就足以在情节提要中显示路线视图控制器。不需要每个选项卡。尝试此操作,因为不需要将导航控制器对象传递给当前vie:[currentVC presentViewController:appViewController动画:无完成:无];