繁体   English   中英

由于以下错误,Segue无法执行“ Receiver(

[英]Segue won't perform due to this error “Receiver (<ViewController: ) has no segue with identifier” but segue is identified

我整天都遇到了同样的错误,我知道这是在故事板上没有识别出segue,而是这样。 以下是我认为相关的代码:1.IBAction表示正在发出信号的按钮。

-(IBAction)launchScanner:(id)sender{
    NSLog(@"launch Scanner pressed");
    [self performSegueWithIdentifier:@"launchScanner" sender:self];     
}
  1. 这是segue功能的准备工作,我暂时将其留空,不确定是否需要在其中包含某些内容。

     -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if([[segue identifier] isEqualToString:@"launchScanner"]){ } } 
  2. 我最初以编程方式进行了所有操作,这是我实例化导航控制器的方式(这在appdelegate.m中):

     ViewController *myViewController = [[ViewController alloc] init]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController]; _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; _window.rootViewController = navigationController; [_window makeKeyAndVisible]; 
  3. 另外,这是我的情节提要设置的图片,以及证明已识别出segue的图片图像1 图像2

如果要以编程方式实例化导航控制器,则需要从情节提要中获取对其的引用。 如果需要在加载初始VC之前在应用程序委托中执行某些功能,则可以使用此功能。

    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
    UINavigationController *initialNavVc = (UINavigationController *)[mainStoryboard instantiateInitialViewController];
    self.window.rootViewController = initialNavVc;

您的情节提要中有一个错误。 导航控制器应为“ Intial View Controller”。 请检查图像中的突出显示 这里

这是校正的情节提要图像的解决方案 在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM