简体   繁体   English

Segue无法从标签栏控制器中的ViewController运行

[英]Segue not working from the viewcontroller inside tabbar controller

I created a tabbar application . 我创建了一个标签栏应用程序。 the root view is tabbar with navigation controller. 根视图是带有导航控制器的标签栏。 When i tried to trigger segue from intial view controller of tabbar, its not working and throwing error in console 当我尝试从标签栏的初始视图控制器触发segue时,它无法正常工作并在控制台中引发错误

" Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'series'" “由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'Receiver()没有标识符为'series'的segue”

    Tabbar Code in appdelegate:

        self.tabBarController = [[UITabBarController alloc] init];
        self.tabBarController.tabBar.barTintColor = [UIColor blackColor];
        self.tabBarController.tabBar.tintColor = [UIColor redColor];

        HomeViewController *VC1 = [[HomeViewController alloc] init];
        VC1.title = @"Home";
        UINavigationController *VC1Navigation = [[UINavigationController alloc]
                                                 initWithRootViewController:VC1];
        wishListViewController *VC2 = [[wishListViewController alloc] init];
        VC2.title = @"My list";
        UINavigationController *VC2Navigation = [[UINavigationController alloc]
                                                 initWithRootViewController:VC2];
        SearchBarVC *vc3 = [[SearchBarVC alloc] init];
        vc3.title = @"Search";
        UINavigationController *VC3Navigation = [[UINavigationController alloc]
                                                 initWithRootViewController:vc3];

        ProfileViewController *vc4 = [[ProfileViewController alloc] init];
        vc4.title = @"More";
        UINavigationController *VC4Navigation = [[UINavigationController alloc]
                                                 initWithRootViewController:vc4];

        NSArray* controllers = [NSArray arrayWithObjects:VC1Navigation, VC2Navigation,VC3Navigation, VC4Navigation, nil];
        self.tabBarController.viewControllers = controllers;

        [[self.tabBarController.tabBar.items objectAtIndex:0] setImage:[UIImage imageNamed:@"homes.png"]];
        [[self.tabBarController.tabBar.items objectAtIndex:1] setImage:[UIImage imageNamed:@"wishlist.png"]];
        [[self.tabBarController.tabBar.items objectAtIndex:2] setImage:[UIImage imageNamed:@"searchs.png"]];
        [[self.tabBarController.tabBar.items objectAtIndex:3] setImage:[UIImage imageNamed:@"dots.png"]];

        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        self.window.backgroundColor = [UIColor whiteColor];
        self.window.rootViewController = self.tabBarController;
        [self.window makeKeyAndVisible];


Segue

[self performSegueWithIdentifier:@"Nav2SingleVid" sender:self];

Please check whether the segue is triggered: 请检查是否触发了segue:

1, Through a user gesture If a segue emanates from a gesture recognizer or from a tappable view, it becomes an action segue, meaning that it will be triggered automatically when the tap or other gesture occurs. 1,通过用户手势如果手势是从手势识别器或可轻击的视图发出的,则它将变成动作手势,这意味着它将在发生轻击或其他手势时自动触发。 Your source view controller class can prevent an action segue from being triggered. 您的源视图控制器类可以防止触发动作序列。 To do so, override this method:shouldPerformSegue(withIdentifier:sender:) 2, in code performSegue(withIdentifier:sender:) 为此,请重写此方法:shouldPerformSegue(withIdentifier:sender :) 2,在代码中performPergue(withIdentifier:sender :)

The default implementation of this method does nothing; 此方法的默认实现不执行任何操作。 you can override it to pass relevant data to the new view controller or window controller, based on the context of the segue. 您可以基于segue的上下文覆盖它,以将相关数据传递到新的视图控制器或窗口控制器。 The segue object describes the transition and includes references to both controllers involved in the segue. segue对象描述过渡,并包括对segue中涉及的两个控制器的引用。

Segues can be triggered from multiple sources, so use the information in the segue and sender parameters to disambiguate between different logical paths in your app. Segues可以从多个来源触发,因此请使用segue和sender参数中的信息来消除应用程序中不同逻辑路径之间的歧义。 For example, if the segue originated from a table view, the sender parameter would identify the cell that the user clicked. 例如,如果segue源自表视图,则sender参数将标识用户单击的单元格。 You could use that information to set the data on the destination view controller. 您可以使用该信息在目标视图控制器上设置数据。

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

相关问题 在一个标签栏控制器中从一个ViewController切换到另一个ViewController? - Segue from one ViewController to another ViewController inside a Tab Bar Controller? 从UITableViewCell到ViewController的Segue无法正常工作 - Segue from UITableViewCell to ViewController not working Segue到TabBar控制器 - Segue to TabBar Controller dismissview控制器在splitView或tabBar控制器中不起作用 - dismissview controller is not working inside splitView or tabBar controller 将Segue从ViewController推送到TableViewController不起作用 - Push segue from ViewController to a TableViewController not working 如果通过segue从另一个Tab进入,如何从控制器中删除TabBar? - How to Remove TabBar from a controller if coming in from another Tab by segue? 如何显示tabBar然后选择其他viewController并返回到此? - How to show tabBar then segue to other viewController and return to this? 从tabbar控制器打开带有后退按钮的独立ViewController - Opening a Separate ViewController with back button from a tabbar controller 从后台启动选项卡控制器堆栈中的viewcontroller(iOS-Swift) - Launch a viewcontroller in a stack of tabbar controller from background (iOS-Swift) 从标签栏打开导航 controller,并在第一个 ViewController 上使用后退按钮 - Opening a navigation controller from Tabbar with back button on first ViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM