gpt4 book ai didi

ios - 由于此错误 "Receiver (
转载 作者:行者123 更新时间:2023-11-29 01:30:57 29 4
gpt4 key购买 nike

我一整天都遇到同样的错误,我知道这是在说 Storyboard 中没有识别出 segue,但确实如此。以下是我认为相关的代码:1.为 segue 发出信号的按钮的 IBAction。

-(IBAction)launchScanner:(id)sender{
NSLog(@"launch Scanner pressed");
[self performSegueWithIdentifier:@"launchScanner" sender:self];
}
  1. 这是 prepare for segue 函数,我暂时将其留空,不确定是否需要在其中包含一些内容。

    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([[segue identifier] isEqualToString:@"launchScanner"]){

    }
    }
  2. 我最初以编程方式制作所有内容,这是我实例化导航 Controller 的方式(在 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. 此外,这是我的 Storyboard设置的图片和证明已识别 segue 的证据 Image 1 Image 2

最佳答案

如果您想以编程方式实例化您的导航 Controller ,您需要从 Storyboard 中获取对它的引用。如果您需要在加载初始 VC 之前在应用程序委托(delegate)中执行某些功能,则可以使用它。

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

关于ios - 由于此错误 "Receiver (<ViewController: ) has no segue with identifier",Segue 将无法执行,但已识别出 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33470091/

29 4 0

Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com