简体   繁体   中英

How to select specific view controller from tabbarcontroller?

I am creating tabbarcontroller using IB that contain 5 tabs, Every tab contain series of view controller.

tab1- view1-view2

tab2 - view3

tab3 - view4-view5-view6

tab4 - view7

tab5 - view8-view9

here i am using uilocalnotification after clicking on notification i want to open view6 from tab3.

This is my code

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

    UIApplicationState state = [application applicationState];

    if (state == UIApplicationStateInactive) {

        application.applicationIconBadgeNumber = 0;
        [[UIApplication sharedApplication] cancelAllLocalNotifications];

    view6 *v6 = [[view6 alloc] initWithNibName:@"view6" bundle:nil];
     [v6 showmyvalues]; //showmyvalues is the method in view6

    }
}

I also try this code

view6 *v6 = [[view6 alloc] initWithNibName:@"view6" bundle:nil];
    UINavigationController *navigationController =
    [[UINavigationController alloc] v6];


    [tabBarController.selectedViewController.navigationController 
     pushViewController:navigationController animated:YES];

Your question is not very clear. Please provide a more detailed explanation as to what you are trying to do and what is actually happening.

From what I understood, I feel that you have to put a viewController on screen based on certain conditions. Try these tips(only for debugging):

  1. Keep a global variable which stores certain value based on what viewController you have to present on screen.

  2. Look into methods UIViewController's methods like viewDidLoad, viewWillAppear, etc and this should be the place where you check your global variable to decide what view controller should be presented.

Also, have a look at this post .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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