无法从appdelegate推送viewcontroller

Zor*_*oro 1 uiactionsheet pushviewcontroller ios appdelegate

  1. 在我的窗口基础应用程序中,我需要从我的appdelegate导航到editorview,当我点击我的tabbarcontroller的第二项时,它将显示一个带有三个选项的动作表.

  2. actionsheet工作正常,如果从tabbar中选择第二项,它将显示一个操作表.

  3. 但是当我选择行动表的第一个选项时,我需要推送到另一个视图

  4. 我在appdelegate中声明我的动作表.

  5. 我已经实现了actionsheetdelegate

    • (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

该方法是trigerred,它可以显示我是否做nslog.但它无法推送到我想要的viewcontroller ..这是我的代码:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        if (buttonIndex == 0)
        {
            DetailViewController *v2 = [[DetailViewController alloc] init];

            NSLog(@"PUSH TRIGER");

            [self.window.rootViewController.navigationController pushViewController:v2 animated:YES];
        }
    }
Run Code Online (Sandbox Code Playgroud)

注意:我已经在我的故事板中嵌入了tabbarcontroller和导航控制器

Ale*_*iro 10

它充满了与此问题相关的错误答案.

我希望我的符合你的要求.

1.-里面

- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
Run Code Online (Sandbox Code Playgroud)

// 1.-首先:实例化navigationController.通常是rootviewcontroller

 UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
Run Code Online (Sandbox Code Playgroud)

// 2.-第二:实例化故事板//它可能被标记为MainStoryBoard.如果你改变它要小心

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
Run Code Online (Sandbox Code Playgroud)

// 3.-第三次实例化你要导航的VC //在我的特定情况下,它被称为IniciarSliderViewController.不要忘记在appdelegate中导入它.还要注意正确标记.在我的情况下MenuSlider

IniciarSliderViewController *controller = (IniciarSliderViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"MenuSlider"];
Run Code Online (Sandbox Code Playgroud)

//4.-最后一个,你现在可以像往常一样在VC中推送

[navigationController pushViewController:controller animated:YES];
Run Code Online (Sandbox Code Playgroud)

不要犹豫,问你是否还有问题